Minor code improvements, more javadoc.