Adding javadoc, extracting method, check style fixes