Added phpdoc comments and made some cleanups