restructuring some methods for easier JVM JITing