Some tidying up and commenting