Add documentation and improve function names

Added documentation to all functions and at some places in the code
outside of locallib.php.
Changed the names of the functions in renderer.php.