fixing errors
more fixing and tidying up