getCacheCmd (CmdCache carr) (CmdTag cind cn) = do
  (mcmd,_) <- liftIO $! readArray carr cind
  case mcmd of
    Just _  -> return mcmd
    Nothing -> do
       mcmd2 <- getCmdNS cn
       case mcmd2 of
         Nothing  -> return Nothing
         Just cmd -> do
           let act al = cmd `applyTo` al
           let jact = Just act
           liftIO $ writeArray carr cind (jact,cn)
           return jact
getCacheCmd (CmdCache carr) (CmdTag cind cn) = do
  (mcmd,_) <- liftIO $! readArray carr cind
  case mcmd of
    Just _  -> return mcmd
    Nothing -> do
       mcmd2 <- getCmdNS cn
       case mcmd2 of
         Nothing  -> return Nothing
         Just cmd -> do
           let act al = cmd `applyTo` al
           let jact = Just act
           liftIO $ writeArray carr cind (jact,cn)
           return jact
getCacheCmd (CmdCache carr) (CmdTag cind cn) = do
  (mcmd,_) <- liftIO $! readArray carr cind
  case mcmd of
    Just _  -> return mcmd
    Nothing -> do
       mcmd2 <- getCmdNS cn
       case mcmd2 of
         Nothing  -> return Nothing
         Just cmd -> do
           let act al = cmd `applyTo` al
           let jact = Just act
           liftIO $ writeArray carr cind (jact,cn)
           return jact