Performance Improvements

Misc performance improvements, including some simple perf tests, which may not be the most accurate on the planet (will vary quite a lot between machines I guess)