CRM-12468 preliminary tidy up - whitespace, missing ts

Note that this should be pulled into 4.3 as it is just to get the code ready to work on (removing trailing spaces). Am not sure yet as to whether the issue fix will go in 4.3