tidied code and changes over past 2 weeks