RST (Image alternate (source', tit)) = do
  let source = unescapeURI source'
  pics <- get >>= return . stImages
  let labelsUsed = map fst pics 
  let txt = if null alternate || alternate == [Str ""] ||
               alternate `elem` labelsUsed
               then [Str $ "image" ++ show (length pics)]
               else alternate
  let pics' = if (txt, (source, tit)) `elem` pics
                 then pics
                 else (txt, (source, tit)):pics
  modify $ \st -> st { stImages = pics' }
  label <- inlineListToRST txt
  return $ "|" <> label <> "|"
inlineT
inlineToRST (Image alternate (source', tit)) = do
  let source = unescapeURI source'
  pics <- get >>= return . stImages
  let labelsUsed = map fst pics 
  let txt = if null alternate || alternate == [Str ""] ||
               alternate `elem` labelsUsed
               then [Str $ "image" ++ show (length pics)]
               else alternate
  let pics' = if (txt, (source, tit)) `elem` pics
                 then pics
                 else (txt, (source, tit)):pics
  modify $ \st -> st { stImages = pics' }
  label <- inlineListToRST txt
  return $ "|" <> label <> "|"
inlineToRST (Image alternate (source', tit)) = do
  let source = unescapeURI source'
  pics <- get >>= return . stImages
  let labelsUsed = map fst pics 
  let txt = if null alternate || alternate == [Str ""] ||
               alternate `elem` labelsUsed
               then [Str $ "image" ++ show (length pics)]
               else alternate
  let pics' = if (txt, (source, tit)) `elem` pics
                 then pics
                 else (txt, (source, tit)):pics
  modify $ \st -> st { stImages = pics' }
  label <- inlineListToRST txt
  return $ "|" <> label <> "|"