General code tidying