lots of bugs fixing