added comments and some phpdoc blocks