greatly improved readability and fixed up javadoc comments