fixed lots of small bugs