Rewrite the profiler
Merge pull request #74 from florianv/profiler2

Rewrite the profiler. Thanks @florianv