add exit functions if civicrm is not initialised
whitespace tidy up
api upgrade - switch to v3 function