diff --git uc_eway.module uc_eway.module
index 4555dba..5a9410c 100755
--- uc_eway.module
+++ uc_eway.module
@@ -147,10 +147,10 @@ function uc_eway_payment_gateway() {
  */
 function uc_eway_order($op, &$arg1, $arg2) {
   switch($op) {
-    case 'update':
+    case 'submit':
       // In case an anonymous user purchases a recurring product, the eway rebill customer id must
       // be allocated to the user after the fact, when the user has an account.
-      if ($arg1->order_status == 'pending' && isset($arg1->data['eway_rebill_customer_id']) && $arg1->uid != 0) {
+      if (isset($arg1->data['eway_rebill_customer_id']) && $arg1->uid != 0) {
         $account = user_load(array('uid' => $arg1->uid));
         $account = user_save($account, array('eway_rebill_customer_id' => $arg1->data['eway_rebill_customer_id']));
 
@@ -199,7 +199,7 @@ function uc_eway_settings_form() {
       'cvn_xml' => t('CVN (XML)'),
       'beagle' => t('Beagle Anti-Fraud'),
     ),
-    '#default_value' => variable_get('uc_eway_mode', UC_EWAY_MODE_DEFAULT),
+    '#default_value' =>variable_get('uc_eway_mode', UC_EWAY_MODE_DEFAULT) ,
   );
   $form['eway_settings']['uc_eway_change_order_status'] = array(
     '#type' => 'select',
@@ -325,8 +325,9 @@ function uc_eway_charge($order_id, $amount, $data) {
   $customer_address .= uc_get_zone_code($order->billing_zone) . ' ';
   $customer_address .= $customer_address_countrycode;
 
+  $cust_id = _uc_eway_get_data('customer_id');
   $xml_data = array(
-    'ewayCustomerID' => variable_get('uc_eway_customer_id', UC_EWAY_CUSTOMER_ID_DEFAULT),
+    'ewayCustomerID' => $cust_id,
     'ewayTotalAmount' => uc_currency_format($amount, FALSE, FALSE, ''),
     'ewayCustomerFirstName' => $order->billing_first_name,
     'ewayCustomerLastName' => $order->billing_last_name,
@@ -344,9 +345,9 @@ function uc_eway_charge($order_id, $amount, $data) {
     'ewayOption2' => '',
     'ewayOption3' => '',
   );
-
-  $eway_testing = variable_get('uc_eway_test_mode', UC_EWAY_TEST_MODE_DEFAULT);
-  switch (variable_get('uc_eway_mode', UC_EWAY_MODE_DEFAULT)) {
+   $eway_testing = variable_get('uc_eway_test_mode', UC_EWAY_TEST_MODE_DEFAULT);
+  
+  switch (_uc_eway_get_data('uc_eway_mode')) {
     case 'merchant_xml':
       $url = ($eway_testing) ? 'https://www.eway.com.au/gateway/xmltest/testpage.asp' : 'https://www.eway.com.au/gateway/xmlpayment.asp';
       break;
@@ -362,7 +363,7 @@ function uc_eway_charge($order_id, $amount, $data) {
       $xml_data['ewayCustomerBillingCountry'] = $customer_address_countrycode;
       break;
   }
-
+  
   $xmlstring = '<ewaygateway>';
   foreach ($xml_data as $key => $value) {
     $xmlstring .= '<' . $key . '>' . htmlentities($value) . '</' . $key . '>';
@@ -370,7 +371,7 @@ function uc_eway_charge($order_id, $amount, $data) {
   $xmlstring .= '</ewaygateway>';
 
   $return_info = uc_eway_process_request($xmlstring, $url);
-
+    
   if (array_key_exists('txStatus',$return_info['eway_response'])) {
   switch ($return_info['eway_response']['txStatus']) {
     case 'false':
@@ -403,13 +404,13 @@ function uc_eway_charge($order_id, $amount, $data) {
       uc_order_comment_save($order_id, NULL, $result['comment'], 'admin');
       // Leave a comment for the customer
       uc_order_comment_save($order_id, NULL, $result['comment'], 'order', NULL, TRUE);
-
+      
       break;
   }
   // Invoke a ca trigger to notify that the payment has been processed
   ca_pull_trigger('uc_eway_payment_processed', $order);
+  
   }
-
   return $result;
 }
 
@@ -435,7 +436,6 @@ function uc_eway_process_request($xml, $url) {
   }
   else {
     curl_close($curl_connection);
-
     $xtr = simplexml_load_string($data);
     $response_details = explode(',', $xtr->ewayTrxnError);
 
@@ -459,4 +459,27 @@ function uc_eway_process_request($xml, $url) {
   }
 }
 
+/**
+ * Helper function to get data, do checking if it's in test mode
+ */
+function _uc_eway_get_data($key){
+  $eway_testing = variable_get('uc_eway_test_mode', UC_EWAY_TEST_MODE_DEFAULT);
+  $return_val;
+  switch($key) {
+    case 'customer_id':
+      $return_val = $eway_testing ? UC_EWAY_CUSTOMER_ID_DEFAULT : variable_get('uc_eway_customer_id', UC_EWAY_CUSTOMER_ID_DEFAULT);
+      break;
+    case 'user_name':
+      $return_val = $eway_testing ? UC_EWAY_EMAIL_ADDRESS_DEFAULT : variable_get('uc_eway_email_address', UC_EWAY_EMAIL_ADDRESS_DEFAULT);
+      break;
+    case 'password':
+      $return_val = $eway_testing ? UC_EWAY_PASSWORD_DEFAULT : variable_get('uc_eway_password', UC_EWAY_PASSWORD_DEFAULT);
+      break;
+    case 'uc_eway_mode':
+      $return_val = $eway_testing ? UC_EWAY_MODE_DEFAULT : variable_get('uc_eway_mode', UC_EWAY_MODE_DEFAULT);
+      break;
+  }
+  return $return_val;
+}
+
 
diff --git uc_eway.recurring.inc uc_eway.recurring.inc
index e1f2c57..86131e2 100644
--- uc_eway.recurring.inc
+++ uc_eway.recurring.inc
@@ -46,27 +46,30 @@ function uc_eway_recurring_process($order, &$fee) {
   // is this user already a rebill customer?
   if (!$account->eway_rebill_customer_id) {
     watchdog('uc_eway_recurring', 'Creating new Rebill CustomerID for user %uid.', array('%uid' => $account->uid));
-    $account = _uc_eway_recurring_create_rebill_customer($order);
+    $rebill_cust_id = _uc_eway_recurring_create_rebill_customer($order);
+    $order->data['eway_rebill_customer_id'] = $rebill_cust_id;
+    //$account = _uc_eway_recurring_create_rebill_customer($order);
   }
   else {
-    watchdog('uc_eway_recurring', 'Using existing Rebill CustomerID (%customer_id) for user %uid.', array('%customer_id', $account->eway_rebill_customer_id, '%uid' => $user->uid));
+    $rebill_cust_id = $account->eway_rebill_customer_id;
+    watchdog('uc_eway_recurring', 'Using existing Rebill CustomerID (%customer_id) for user %uid.', array('%customer_id' => $account->eway_rebill_customer_id, '%uid' => $user->uid));
   }
 
   // how about now?
-  if (!$account->eway_rebill_customer_id) {
+  if (!$rebill_cust_id) {
     watchdog('uc_eway', 'Failed to create Rebill Customer');
     return FALSE;
   }
 
   // create a rebill event
-  $result = _uc_eway_recurring_create_rebill_event($order, $fee, $account);
+  $result = _uc_eway_recurring_create_rebill_event($order, $fee, $rebill_cust_id);
 
   if ($result['error']) {
     watchdog('uc_eway_recurring', 'Failed to create Rebill Event: %error', array('%error' => $result['ErrorDetails']));
     return FALSE;
   }
   else {
-    watchdog('uc_eway_recurring', 'Created Rebill Event: %rid', array('%rid', $result['RebillID']));
+    watchdog('uc_eway_recurring', 'Created Rebill Event: %rid', array('%rid' => $result['RebillID']));
     $fee->data['rebill_id'] = $result['RebillID'];
     return TRUE;
   }
@@ -84,7 +87,18 @@ function uc_recurring_eway_renew($order, $fee) {
   // get all transactions, test if this fee went through
   if (count($result['Successful']['QueryTransactionsResult'])) {
     watchdog('uc_eway_recurring', 'Renew charged for fee: %fee, Transaction status is SUCCESSFUL: %result', array('%fee' => var_export($fee, TRUE), '%result' => var_export($result['Successful'], TRUE)));
-    return TRUE;
+    // create new rebill event for infinite interval (-1)
+    if($fee->remaining_intervals < 0){
+      $return = _uc_eway_recurring_create_rebill_event($order, $fee, $order->uid);
+      if($return['error'] == 0){
+        watchdog('uc_eway_recurring', 'CreateRebillEvent for infinite interval succeded, Response: %response', array('%response' => var_export($return, TRUE)));
+        return TRUE;
+      }else{
+        watchdog('uc_eway_recurring', 'CreateRebillEvent for infinite interval failed, Response : %response', array('%response' => var_export($return, TRUE)));
+        return FALSE;
+      }
+    }
+    else return TRUE;
   }
   else if (count($result['Failed']['QueryTransactionsResult'])) {
     watchdog('uc_eway_recurring', 'Renew failed for fee: %fee, Transaction status is FAILED: %result', array('%fee' => var_export($fee, TRUE), '%result' => var_export($result['Failed'], TRUE)));
@@ -145,9 +159,9 @@ function _uc_eway_recurring_soap_call($operation, $params) {
   $endpoint = variable_get('uc_eway_test_mode', UC_EWAY_TEST_MODE_DEFAULT) ? 'https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx?WSDL' : 'https://www.eway.com.au/gateway/rebill/manageRebill.asmx?WSDL';
   $namespace = 'http://www.eway.com.au/gateway/rebill/manageRebill';
   $header = '<eWAYHeader xmlns="http://www.eway.com.au/gateway/rebill/manageRebill"> 
-    <eWAYCustomerID>' . variable_get('uc_eway_customer_id', UC_EWAY_CUSTOMER_ID_DEFAULT) . '</eWAYCustomerID> 
-    <Username>' . variable_get('uc_eway_email_address', UC_EWAY_EMAIL_ADDRESS_DEFAULT)  . '</Username> 
-    <Password>' . variable_get('uc_eway_password', UC_EWAY_PASSWORD_DEFAULT)  . '</Password> 
+    <eWAYCustomerID>' . _uc_eway_get_data('customer_id') . '</eWAYCustomerID> 
+    <Username>' . _uc_eway_get_data('user_name')  . '</Username> 
+    <Password>' . _uc_eway_get_data('password')  . '</Password> 
     </eWAYHeader>'; // TODO: replace with soapval
 
   if (@include_once(realpath(uc_eway_recurring_nusoap_path()))) {
@@ -160,6 +174,7 @@ function _uc_eway_recurring_soap_call($operation, $params) {
   }
 
   //if (variable_get('uc_eway_test_mode', UC_EWAY_TEST_MODE_DEFAULT)) {
+    $params['RebillCCNumber'] = '**** **** **** ****'; // Don't log the CC number in plan text.
     watchdog('uc_eway_recurring', 'SOAP Call (%operation) request: %request, response: %response', array('%operation' => $operation, '%request' => var_export($params, TRUE), '%response' => var_export($result, TRUE)));
   //  watchdog('uc_eway_recurring', 'NuSOAP client: %client', array('%client' => var_export($client, TRUE)));
   //}
@@ -199,12 +214,13 @@ function _time($type = 'none') {
  * Create Rebill Customer
  */
 function _uc_eway_recurring_create_rebill_customer($order) {
-  $account = user_load(array('uid' => $order->uid));
+  //$account = user_load(array('uid' => $order->uid));
 
   $country = uc_get_country_data(array('country_id' => $order->billing_country));
-
+  
+  $cust_id = _uc_eway_get_data('customer_id');
   $data = array(
-    'ewayCustomerID' => variable_get('uc_eway_customer_id', UC_EWAY_CUSTOMER_ID_DEFAULT),
+    'ewayCustomerID' => $cust_id,
     'customerTitle' => '',
     'customerFirstName' => (string) $order->billing_first_name,
     'customerLastName' => (string) $order->billing_last_name,
@@ -226,12 +242,10 @@ function _uc_eway_recurring_create_rebill_customer($order) {
 
   $response = _uc_eway_recurring_soap_call('CreateRebillCustomer', $data);
   if ($response['CreateRebillCustomerResult']['Result'] == 'Success') {
-    $account = user_save($account, array(
-      'eway_rebill_customer_id' => $response['CreateRebillCustomerResult']['RebillCustomerID'],
-    ));
+    return $response['CreateRebillCustomerResult']['RebillCustomerID'];
   }
 
-  return $account;
+  return FALSE;
 }
 
 /**
@@ -255,7 +269,7 @@ function _uc_eway_recurring_delete_rebill_customer() {
 /**
  * Create Rebill Event
  */
-function _uc_eway_recurring_create_rebill_event($order, $fee, $account) {
+function _uc_eway_recurring_create_rebill_event($order, $fee, $rebill_cust_id) {
   // create invoice description
   $description = '';
   if (is_array($order->products)) {
@@ -283,17 +297,20 @@ function _uc_eway_recurring_create_rebill_event($order, $fee, $account) {
     case 'months': $interval_type = 3; break;
     case 'years': $interval_type = 4; break;
   }
-  if ($fee->remaining_intervals) {
+  
+  if ($fee->remaining_intervals > 0) {
     // End date has to be calculated from the start date, not the date of purchase, so:
     // +1 regular interval to get to the start date then + (regular interval * remaining intervals to get the number rebills)
     $end_date = date('d/m/Y', strtotime('+' . ($regular_interval[0] + ($regular_interval[0] * $fee->remaining_intervals)) . ' ' . $regular_interval[1]));
   }
   else {
-    $end_date = UC_EWAY_RECURRING_VAST_END_DATE;
+    // If remaining intervals is -1 (infinite)
+    $end_date = date('d/m/Y', strtotime('+' . ($regular_interval[0] * 2). ' ' . $regular_interval[1]));
+    //$end_date = UC_EWAY_RECURRING_VAST_END_DATE;
   }
-
+  
   $data = array(
-    'RebillCustomerID' => $account->eway_rebill_customer_id,
+    'RebillCustomerID' => $rebill_cust_id,
     'RebillInvRef' => $order->order_id,
     'RebillInvDes' => substr($description, 0, 10000),
     'RebillCCName' => $cc_name,
