cleanup code and added benchmarking test.