Fixed a bunch of big bugs.