Tidied up the code base with some comments.