public function getBlocks()
    {
        $ungroupedKey = 'Ungrouped';
        $blockGroups = array();
        foreach ($this->blockManagersItems as $blockManagerItem) {

            if ($blockManagerItem->getBlockManager()->getIsInternalBlock()) {
                continue;
            }

            $groups = array($ungroupedKey);
            $group = $blockManagerItem->getGroup();
            if ($group != "") {
                $groups = explode(",", $group);
                if ($group != "redkitecms_internals" && count($groups) == 1) {
                    $groups = array($ungroupedKey);
                }
            }

            $blockGroup = array($blockManagerItem->getType() => array('description' => $blockManagerItem->getDescription(), 'filter' => $blockManagerItem->getFilter()));
            foreach (array_reverse($groups) as $key) {
               $blockGroup = array(trim($key) => $blockGroup);
            }
            $blockGroups = array_merge_recursive($blockGroups, $blockGroup);
        }

        // First displayed group
        $redKiteBlocks = array("Base" => $this->extractGroup('redkitecms_internals', $blockGroups));
        // Last displayed group
        $notGrouped = $this->extractGroup($ungroupedKey, $blockGroups);
        // Sorts
        $this->recurKsort($redKiteBlocks);
        if (count($notGrouped) > 0) {
            $this->recurKsort($notGrouped);
        }

        // Exstracts and sorts all other groups
        $blocks = array();
        foreach ($blockGroups as $blockGroup) {
            $blocks = array_merge($blocks, $blockGroup);
        }
        $this->recurKsort($blocks);

        // Merges blocks
        $blocks = array_merge($redKiteBlocks, $blocks);
        if ( ! empty($notGrouped)) {
            $blocks = array_merge($blocks, array($ungroupedKey => $notGrouped));
        }

        return $blocks;
    }