Fixed a buncha bugs.