tidying up a little. Added some comments here and there