Minor optimizations; more javadoc