Fixed a bunch of bugs, still a ton of sql problems