public function set(array $config, $merge_globals = true, $stack_name = null)
    {
        if (!empty($config)) {
            $config = $this->_buildConfigStack($config);
            if (!empty($stack_name)) {
                $this->getRegistry()->loadStack($stack_name);
            }
            foreach ($config as $index=>$val) {
                $this->getRegistry()->setEntry($index, $val);
            }
            if (!empty($stack_name)) {
                $this->getRegistry()->saveStack($stack_name);
            }
        }

        if (!$merge_globals) {
            return $config;
        } else {
            $this->getRegistry()->loadStack(self::$global_config_id);
            $globals = array_replace_recursive(
                $this->getRegistry()->dump(), $config
            );
            foreach ($globals as $index=>$val) {
                $this->getRegistry()->setEntry($index, $val);
            }            
            $this->getRegistry()->saveStack(self::$global_config_id);
            return $this;
        }
    }