Refactoring done, commenting done with phpdocs