Adds comments and cleans up the code a little bit. Still needs major refactoring