finally solved pickling issues in automatically generated classes

really a pain. Now each of the generated classes implements a __reduce method
test for pickling models

requires setting up __eq__ functions for most objects