quite a bit of tidying up :-)