Adding profiler function and cleaner exit