Fixed a ton of errors and bugs