Some speed optimizations, khm