more cleanup and some PHPDocs