some hot loop optimizations
Merge pull request #170 from potch/master

some hot loop optimizations