loads of bug fixes