Added Doxygen documentation, and extra comments as description of the code.