Added Doxygen support. Code formatted and cleaned up.