Fixed a bunch a bugs