Fix profiling feedback formatting

This both fixes the broken output, and also refactors the code.

Not sure how to test this, so might need more refactoring to make this testable.