Fixed lots of small bugs