Fix serialization issue

Fixes BXC 5667 - SerializationException: The object with ID 1 could not be resolved

Tests are passing. Pending of a final review.