Recreate factory after pickling resource.

Instead of pickling factory too - this is to prevent users pickling a
factory, since it makes no sense.