Wrote and fixed lots of tests and did tons of other stuff

Random fact: This entire branch was done in the browser, using Github as a file editor and Travis as a builder/tester.
Update: Then I did more in Eclipse.