some hot loop optimizations