Fixed a bunch of bugs, commented a bunch of code