Added some instrumentation. Some cleanup for -O3