Added documentation, and cleaned up the code.