Code cleanup and some comments added

This is all because I started using PHPStorm. I love this IDE.