More fixes and tidying up