fixed lots of bugs.