Fixed lots of bugs.