Updating to add documentation and clean up code.