Large overhaul by Sergey Alexandrov.
Remove some obsolete comments, add comments etc
Make sure to sanitize user input from piVars
Fix a typo in the injectObjects code