Optimizations with Profiler

Using the Profiler to find the time consuming elements and breaking
them apart.