Fix loads of bugs