Profiling + optimization

I created a new variant named *profiler* that compiles with ```-O2 -g``` and lins with gperftools' CPU profiler library. I could not make the profiler work however, so I ran profiling with Callgrind instead. I made some optimizations from the results.