Final cleanup.

Added DOxygen comments and performed general cleanup of the code.