Fixed issue when trying to pickle model instances