Inline micro-optimizations

This inlines a bunch of functions that may be on the critical path, which can help llvm to speed up some inner loops.