public function finishGlobalModification($commit) {
        if (!$this->globalModificationStarted) {
            throw new IllegalStateException(t('Meta Model modification has not been started'));
        }

        $this->globalModificationStarted = FALSE;

        if (isset($this->cachedMetaModel)) {
            if ($commit) {
                $this->cachedMetaModel->markAsAssembled();

                // checking if someone updated the meta model while we were in global modification transaction
                $externalCachedMetaModel = $this->loadCachedMetaModel();
                if (isset($externalCachedMetaModel)) {
                    if ($externalCachedMetaModel->version == $this->cachedMetaModel->version) {
                        $this->cacheMetaModel($this->cachedMetaModel);
                    }
                    else {
                        // we need to remove data from external cache
                        // because different version of the meta model was changed and the cached meta model became obsolete
                        $this->releaseFromSharedCache();
                    }
                }
            }
            else {
                // rolling back whatever we tried to change without removing external cache
                $this->releaseFromLocalCache();
            }
        }
    }