Reimplement the toJSON/Prototype workaround

Stop results JSON from getting mangled.