Fixed a bunch of bugs and added a few things.