Tidying

Added some comments and tidied some code