Minor fixes and some modification to the profiling.