Squash

Fixed a bunch of bugs. Some of the fixes are a bit sketchy, let me know if any of them look *too* sketchy and I can fix them.