added cleanup of referenced object ids

Signed-off-by: Alexander Knapstein <alexander.knapstein@inspirationlabs.com>