Fixed a buncha bugs