General tidying up code