added robust pickling, switches to old behaviour, if get/setstate not implemented