Finish PHPLibrary funtions refactor