Benchmarking and refactoring. A bit of a mess at the moment.