Various profiling and other fixes.