Fixed a lot more bugs