tidying up code, some comment additions