Tidying things up, and adding comments