Added profiling support. Replaced std::fill with memset.