fix countEntityInRelations
ensure that temporary entities are removed
use correct interface for accessing entities