Fixed a lot of bugs, essentially beta commit.