updates and code tidying