Tidied up some code and comments.