Google App Engine Contacts Services error
===

First, I know, there is a [similar question][1] but it's just similar and not the same :)

This script import Google Contacts -> [Contacts Sevices][2], in a spreadsheet.

    function onOpen()
    {
      var menuItems = [{name: "Gmail Contact Import", functionName: "getContacts"}];
      SpreadsheetApp.getActiveSpreadsheet().addMenu("import", menuItems);
    }
    
    function getContacts()
    {
      var groupName = "MyGroup";
      var contacts;
      var sheet = SpreadsheetApp.getActiveSheet();
      
      if (groupName) {
        var contactGroup = ContactsApp.findContactGroup(groupName);
        
        if (contactGroup) {
          contacts = contactGroup.getContacts();
        }
      } 
      else {
        contacts = ContactsApp.getAllContacts();
      }
      
      if (!contacts) {
        Browser.msgBox("no contacts found!");
        return;
      }  
      
      sheet.clear();
      
      sheet.getRange("A1").setValue("forename");
      sheet.getRange("B1").setValue("lastname");
      sheet.getRange("C1").setValue("private email");
      sheet.getRange("D1").setValue(groupName + " email");
      sheet.getRange("E1").setValue("phone");
      sheet.getRange("F1").setValue("mobile");
      sheet.getRange("G1").setValue("street");
      sheet.getRange("H1").setValue("zip");
      sheet.getRange("I1").setValue("city");
      sheet.getRange("J1").setValue("group");
      sheet.getRange("K1").setValue("date1");
      sheet.getRange("L1").setValue("date2");
      sheet.getRange("M1").setValue("date3");
      sheet.getRange("N1").setValue("date4");
    
      for ( var i = 0; i < contacts.length; i++) {
        var addressArray = new Array();
        addressArray = contacts[i].getAddresses(ContactsApp.Field.HOME_ADDRESS);
        var addressArrayLength = addressArray.length;    
        for ( var ii = 0; ii < addressArrayLength; ii++ ) {
          var address = addressArray[ii].getAddress();
          var addressSplit = address.split(/\r\n|\r|\n/);
          var street = addressSplit[0];
          var city = addressSplit[1].split(" ")[0];
          var zip = addressSplit[1].split(" ")[1];
        }
        var homePhone = contacts[i].getHomePhone().replace("0049-","0").toString();
        var mobilePhone = contacts[i].getMobilePhone().replace("0049-","0").toString();
        var fireMail = ""
        var privateMail = "";
        var mailArray = new Array();
        mailArray = contacts[i].getEmails(ContactsApp.Field.HOME_EMAIL);
        var mailArrayLength = mailArray.length;    
        for ( var ii = 0; ii < mailArrayLength; ii++ ) {
          privateMail = contacts[i].getEmails(ContactsApp.Field.HOME_EMAIL)[ii].getAddress();
        }
        
        if (!privateMail)
        {
          mailArray = contacts[i].getEmails(ContactsApp.Field.WORK_EMAIL);
          mailArrayLength = mailArray.length;
          
          for ( var ii = 0; ii < mailArrayLength; ii++ ) {
            privateMail = contacts[i].getEmails(ContactsApp.Field.WORK_EMAIL)[ii].getAddress();
          }
        }
            
        mailArray = contacts[i].getEmails(groupName);
        mailArrayLength = mailArray.length;
        
        for ( var ii = 0; ii < mailArrayLength; ii++ ) {
          fireMail = contacts[i].getEmails(groupName)[ii].getAddress();
        }
        
        sheet.getRange(1*i+2, 1, 1, 1).setValue(contacts[i].getGivenName());
        sheet.getRange(1*i+2, 2, 1, 1).setValue(contacts[i].getFamilyName());
        sheet.getRange(1*i+2, 3, 1, 1).setValue(privateMail);
        sheet.getRange(1*i+2, 4, 1, 1).setValue(fireMail);
        sheet.getRange(1*i+2, 5, 1, 1).setValue(homePhone);
        sheet.getRange(1*i+2, 6, 1, 1).setValue(mobilePhone);
        sheet.getRange(1*i+2, 7, 1, 1).setValue(street);
        sheet.getRange(1*i+2, 8, 1, 1).setValue(zip);
        sheet.getRange(1*i+2, 9, 1, 1).setValue(city);
        
        var groups = contacts[i].getContactGroups();
        
        for ( var j = 0; j < groups.length; j++) {
          var name = groups[j].getName();
          switch (name) {
            case "group1":
              sheet.getRange(1*i+2, 10, 1, 1).setValue(1);
              break;
            case "group2":
              sheet.getRange(1*i+2, 10, 1, 1).setValue(2);
              break;
            case "group3":
              sheet.getRange(1*i+2, 10, 1, 1).setValue(3);
              break;
            case "group4":
              sheet.getRange(1*i+2, 10, 1, 1).setValue(4);
              break;
            case "group5":
              sheet.getRange(1*i+2, 10, 1, 1).setValue(5);
              break;
            default:
              break;
          }
          
          if (name.indexOf("datetrigger1") > -1)
          {
            var dateArray = contacts[i].getDates("date1");
            var dateArrayLength = dateArray.length;        
            for ( var ii = 0; ii < dateArrayLength; ii++ ) {
              var date = contacts[i].getDates("date1")[ii];
              var day = date.getDay();
              var month = date.getMonth();
              var year = date.getYear();
              sheet.getRange(1*i+2, 11, 1, 1).setValue(day.toString() + "." + month.toString() + "." + year.toString());
            }
            sheet.getRange(1*i+2, 11, 1, 1).setBackgroundColor('green');
          }
          
          if (name.indexOf("datetrigger2") > -1)
          {
            var dateArray = contacts[i].getDates("date2");
            var dateArrayLength = dateArray.length;        
            for ( var ii = 0; ii < dateArrayLength; ii++ ) {
              var date = contacts[i].getDates("date2")[ii];
              var day = date.getDay();
              var month = date.getMonth();
              var year = date.getYear();
              sheet.getRange(1*i+2, 12, 1, 1).setValue(day.toString() + "." + month.toString() + "." + year.toString());
            }
            sheet.getRange(1*i+2, 12, 1, 1).setBackgroundColor('green');
          }
          
          if (name.indexOf("datetrigger3") > -1)
          {
            var dateArray = contacts[i].getDates("date3");
            var dateArrayLength = dateArray.length;        
            for ( var ii = 0; ii < dateArrayLength; ii++ ) {
              var date = contacts[i].getDates("date3")[ii];
              var day = date.getDay();
              var month = date.getMonth();
              var year = date.getYear();
              sheet.getRange(1*i+2, 13, 1, 1).setValue(day.toString() + "." + month.toString() + "." + year.toString());
            }
            sheet.getRange(1*i+2, 13, 1, 1).setBackgroundColor('green');
          }
          
          if (name.indexOf("datetrigger4") > -1)
          {
            var dateArray = contacts[i].getDates("date4");
            var dateArrayLength = dateArray.length;
            if (dateArrayLength > 0) {
              for ( var ii = 0; ii < dateArrayLength; ii++ ) {
                var date = contacts[i].getDates("date4")[ii];
                var day = date.getDay();
                var month = date.getMonth();
                var year = date.getYear();
                sheet.getRange(1*i+2, 14, 1, 1).setValue(day.toString() + "." + month.toString() + "." + year.toString());
              }
              sheet.getRange(1*i+2, 14, 1, 1).setBackgroundColor('green');
            }
          }
        }
      }
      
      Browser.msgBox(contacts.length + " contacts imported.");
    }

Works fine, but after the message "xy contacts imported" I get this error message:

> Unexpected exception upon serializing continuation

I cannot figure out what's wrong.

  [1]: http://stackoverflow.com/questions/10954075/unexpected-exception-upon-serializing-continuation
  [2]: https://developers.google.com/apps-script/service_contacts