speedups, and some profiling helpers