Added benchmarks and made a few optimizations