Performance fixes

Saving is now ~20,000% faster.