Removed more duplication and white space, fixed PHPdoc comments and added class constants.