Refactoring. Cleaning code and phpdocs.