this is a bit expensive at the moment  because it is called twice on serialization  the way to get around this is to use setupcontext teardowncontext this seems to keep coming up  maybe we should just fix  