Profiler support

Proper support for heap snapshots and cpu profiling.