lots of bugs corrected