Fixed a bunch of bugs, tweaked things