lots of bug fixes and stuff