CRM-12333 and lots of formatting fixes

----------------------------------------
* CRM-12333: Unescaped items in upgrade SQL script
  http://issues.civicrm.org/jira/browse/CRM-12333
Merge pull request #410 from dlobo/CRM-12333

CRM-12333 and lots of formatting fixes