Original vershion with minor modifications for the tests/benchmarks