Humongous code cleanup. Tons of javadoc added.
No functionality changes, just changes to the way in which functions are
called, handled, etc.