Fixed a bunch of random bugs