lots of bugs fixed