Fixed a whole bunch of misc issues and made a few improvements