fix up a whole heap of stuff