Added Doxygen compatible comments. Got rid of some unnecessary code and did some style changes.