Fixed a bunch of bugs, many more to fix.