Created documentation and updated comments. Also cleaned up some of the code.