Tidied up the code, added documentation both inline and as javadoc