Code formatting to PSR1/PSR2 and symfony styles. Added quite a few PHPDOC style comments