Added javadoc and tidied up code for debug class