Small tweak to performance test.
Fix some optimization issues. All tests pass.