Added benchmark define
some code cleanup and speedups