massive tidy up and additions to db and models