fixing a whole range of bugs and exploits