Added a timer and some profiling code.