Implement benchmark mode
Minor optimizations