Fix undefined constants and some phpdoc