Code tidying ready to make public