Additional coding, tidying up