fixed a bunch of things I messed up, added comments
merge changes