Added somemore comments and tidied up.