Cleaned code and fixed typo in javadoc.