Updated documentation and cleaned up the code.