Made more PSR compliant. Fixed a potential issue with using array access with objects accidentily. Added missing doc blocks, and updated some existing ones.