Added some profiling code. This should be removed sometime.