Merge pull request #616 from kurund/CRM-12463-fixes

CRM-12463 fixes
Merge pull request #617 from kurund/CRM-12463-fixes

more work on CRM-12463, form building js fixes
Merge pull request #618 from kurund/CRM-12463-fixes

whitespace fixes
worked on CRM-12463, more cleanup