edit comments, minor code optimisation