Fixed code style and added Javadoc.