Clean code and add phpdoc