Some performance improvements, and a new profiling framework (2)