Added automatic profiling. Turned off by default.