Added a bunch of comments and got rid of some unnecessary code