tidying up and documentation