Added check for duplicate model ids
Added support for identifying cyclic models