Codereview

Turns out github doesn't allow commenting very well on code, so this is code review in the form of a pull request. Each comment is a separate commit.