Changed encode_with_relatives to take additional argument exclude_models, decoder to work with reversed O2O relation