Refactoring the coding style and adding javadoc comments.