Added benchmark, fixed memleaks, and added profiling