Some code refactoring and checking through some of the PHPDocs.