Fix up internal pickling routine