Fixed code indentation and added some javadoc.