some tidying and improvements