Partially rework profiling. Fix profiling crash with new parser. Fixes
1295