Fixed a few bugs, a lot still left.