Fixed a few minor bugs, which should have been done on the first commit.