performance stats and optimization