Updated code to be PSR2 compliant and added some doc blocks and document...

...ed code where it needs it