diff --git a/Main.hs b/Main.hs
new file mode 100644
--- /dev/null
+++ b/Main.hs
@@ -0,0 +1,115 @@
+{-# LANGUAGE CPP #-}
+
+import Control.Monad.State.Lazy (execStateT)
+import Data.List                (intersperse)
+import Lens.Micro.Platform      ((.=))
+import Data.Maybe               (fromMaybe)
+
+import Options.Applicative
+
+import Yi hiding (option)
+import Yi.Config.Simple.Types
+import Yi.Buffer.Misc (lineMoveRel)
+
+import Yi.Config.Default.HaskellMode    (configureHaskellMode)
+import Yi.Config.Default.JavaScriptMode (configureJavaScriptMode)
+import Yi.Config.Default.MiscModes      (configureMiscModes)
+
+#ifdef VIM
+import Yi.Config.Default.Vim (configureVim)
+#endif
+#ifdef VTY
+import Yi.Config.Default.Vty (configureVty)
+#endif
+#ifdef EMACS
+import Yi.Config.Default.Emacs (configureEmacs)
+#endif
+#ifdef PANGO
+import Yi.Config.Default.Pango (configurePango)
+#endif
+
+frontends :: [(String, ConfigM ())]
+frontends = [
+#ifdef PANGO
+  ("pango", configurePango),
+#endif
+#ifdef VTY
+  ("vty", configureVty),
+#endif
+  ("", return ())
+  ]
+
+keymaps :: [(String, ConfigM ())]
+keymaps = [
+#ifdef EMACS
+  ("emacs", configureEmacs),
+#endif
+#ifdef VIM
+  ("vim", configureVim),
+#endif
+  ("", return ())
+  ]
+
+data CommandLineOptions = CommandLineOptions {
+    frontend :: Maybe String
+  , keymap :: Maybe String
+  , startOnLine :: Maybe Int
+  , files :: [String]
+  }
+
+commandLineOptions :: Parser (Maybe CommandLineOptions)
+commandLineOptions = flag' Nothing 
+                       ( long "version" 
+                      <> short 'v' 
+                      <> help "Show the version number") 
+  <|> (Just <$> (CommandLineOptions
+    <$> optional (strOption
+        ( long "frontend"
+       <> short 'f'
+       <> metavar "FRONTEND"
+       <> help "The frontend to use (default is pango)"))
+    <*> optional (strOption
+        ( long "keymap"
+       <> short 'k'
+       <> metavar "KEYMAP"
+       <> help "The keymap to use (default is emacs)"))
+    <*> optional (option auto
+        ( long "line"
+       <> short 'l'
+       <> metavar "NUM"
+       <> help "Open the (last) file on line NUM"))
+    <*> many (argument str (metavar "FILES..."))
+  ))
+
+main :: IO ()
+main = do
+    mayClo <- execParser opts
+    case mayClo of 
+      Nothing -> putStrLn "Yi 0.13.0.1"
+      Just clo -> do
+        let openFileActions = intersperse (EditorA newTabE) (map (YiA . openNewFile) (files clo))
+            moveLineAction  = YiA $ withCurrentBuffer (lineMoveRel (fromMaybe 0 (startOnLine clo)))
+        cfg <- execStateT
+            (runConfigM (myConfig (frontend clo) (keymap clo) >> (startActionsA .= (openFileActions ++ [moveLineAction]))))
+            defaultConfig
+        startEditor cfg Nothing
+  where 
+   opts = info (helper <*> commandLineOptions)
+     ( fullDesc
+    <> progDesc "Edit files"
+    <> header "Yi - a flexible and extensible text editor written in haskell")
+
+myConfig :: Maybe String -> Maybe String -> ConfigM ()
+myConfig f k = do
+  -- Lookup f in the frontends list or pick the first element of the frontends list if
+  -- f is nothing or do nothing if f is not found in the frontends list.
+  case f of
+    Nothing -> snd (head frontends)
+    Just f' -> fromMaybe (return ()) (lookup f' frontends)
+  -- Same as above, but then with k and keymaps
+  case k of
+    Nothing -> snd (head keymaps)
+    Just k' -> fromMaybe (return ()) (lookup k' keymaps)
+  configureHaskellMode
+  configureJavaScriptMode
+  configureMiscModes
diff --git a/src/Main.hs b/src/Main.hs
deleted file mode 100644
--- a/src/Main.hs
+++ /dev/null
@@ -1,27 +0,0 @@
--- | "Real" Frontend to the static binary.
-
-module Main (main) where
-
-import Control.Monad.State
-
-import Yi.Boot (yiDriver')
-import Yi.Config.Default (defaultConfig)
-
-import Yi.Config.Default.Vty
-import Yi.Config.Default.Emacs
-import Yi.Config.Default.HaskellMode
-import Yi.Config.Default.JavaScriptMode
-import Yi.Config.Default.MiscModes
-import Yi.Config.Simple.Types
-
-main :: IO ()
-main = do
-    cfg <- execStateT configure defaultConfig
-    yiDriver' True cfg
-    where
-    configure = runConfigM $ do
-        configureVty
-        configureEmacs
-        configureHaskellMode
-        configureJavaScriptMode
-        configureMiscModes
diff --git a/yi.cabal b/yi.cabal
--- a/yi.cabal
+++ b/yi.cabal
@@ -3,7 +3,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           yi
-version:        0.13.0.2
+version:        0.13.1
 synopsis:       Yi editor
 category:       Yi
 homepage:       https://github.com/yi-editor/yi#readme
@@ -17,18 +17,55 @@
   type: git
   location: https://github.com/yi-editor/yi
 
+flag emacs
+  description: Include the emacs keymap
+  manual: True
+  default: True
+
+flag pango
+  description: Include the pango (GUI) frontend
+  manual: True
+  default: True
+
+flag vim
+  description: Include the vim keymap
+  manual: True
+  default: True
+
+flag vty
+  description: Include the vty (CLI) frontend
+  manual: True
+  default: True
+
 executable yi
   main-is: Main.hs
   hs-source-dirs:
-      src
+      .
   ghc-options: -Wall -ferror-spans -threaded
   build-depends:
       base >= 4.8 && < 5
-    , mtl >= 2.2
-    , yi-core >= 0.13
-    , yi-frontend-vty >= 0.13
-    , yi-keymap-emacs >= 0.13
-    , yi-mode-haskell >= 0.13
-    , yi-mode-javascript >= 0.13
-    , yi-misc-modes >= 0.13
+    , microlens-platform >= 0.3.4.0
+    , mtl >= 2.2.1
+    , optparse-applicative >= 0.12.1.0
+    , yi-core >= 0.13.0.1
+    , yi-misc-modes >= 0.13.0.1
+    , yi-mode-haskell >= 0.13.0.1
+    , yi-mode-javascript >= 0.13.0.1
+    , yi-rope >= 0.7.0.1
+  if flag(vty)
+    cpp-options: -DVTY
+    build-depends:
+        yi-frontend-vty
+  if flag(pango)
+    cpp-options: -DPANGO
+    build-depends:
+        yi-frontend-pango
+  if flag(vim)
+    cpp-options: -DVIM
+    build-depends:
+        yi-keymap-vim
+  if flag(emacs)
+    cpp-options: -DEMACS
+    build-depends:
+        yi-keymap-emacs
   default-language: Haskell2010
