improvements and tidying up