diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,5 +1,23 @@
 #Quickterm [Quick Haskell Terminal Interfaces]
 
+##Examples
+
+Some here: https://github.com/SamuelSchlesinger/Components
+
+Others in examples folder
+
+##Install/Documentation
+
+To install:
+
+> cabal install quickterm
+
+Documentation: https://hackage.haskell.org/package/quickterm-0.1.0.0/docs/Quickterm.html
+
+##Development
+
+Right now I'm taking finals, but in src/Mainable.hs, there is a class which really would make the production of these programs much easier. I plan to rework the system pretty thoroughly to allow for such functions, probably simply by adding another case to the Quickterm class and adding another pattern for each of the functions which take a Quickterm. Hopefully by doing it this way I won't break much. I also want to add some sort of cute error handling device, as right now there is a pretty common pattern in my TerminalAction implementations that simply prints the usage or some error message, and that could probably be relegated to some Error Monad, or something a little more expressive. That's a pretty big change, though, and it would break most of the code I've already written, so I'm probably going to add in the other bit first, push it once more, then make a new version and rework it and refactor it pretty intensively.
+
 ##First Look (Thoughts)
 
 I often want to port certain functions I write to a command line interface. Assuming the existence of various functions which map from a set of command line arguments to an action of type IO (), this involes parsing arguments, options, and generating some usage information which should give you an idea of how to use the application if you go wrong.
@@ -30,4 +48,3 @@
 > usage :: Quickterm -> String -- Generates the usage string
 
 > quickrun :: [String] -> Quickterm -> IO () -- Runs the program on the raw arguments
-
diff --git a/quickterm.cabal b/quickterm.cabal
--- a/quickterm.cabal
+++ b/quickterm.cabal
@@ -1,76 +1,49 @@
--- Initial quickterm.cabal generated by cabal init.  For further 
--- documentation, see http://haskell.org/cabal/users-guide/
-
--- The name of the package.
-name:                quickterm
-
--- The package version.  See the Haskell package versioning policy (PVP) 
--- for standards guiding when and how versions should be incremented.
--- http://www.haskell.org/haskellwiki/Package_versioning_policy
--- PVP summary:      +-+------- breaking API changes
---                   | | +----- non-breaking API additions
---                   | | | +--- code changes with no API change
-version:             0.1.0.0
-
--- A short (one-line) description of the package.
-synopsis:            An interface for describing and executing terminal applications
-
--- A longer description of the package.
--- description:         
-
--- URL for the project homepage or repository.
-homepage:            https://github.com/SamuelSchlesinger/Quickterm
-
--- The license under which the package is released.
-license:             GPL-3
-
--- The file containing the license text.
-license-file:        LICENSE
-
--- The package author(s).
-author:              Samuel Schlesinger
-
--- An email address to which users can send suggestions, bug reports, and 
--- patches.
-maintainer:          sgschlesinger@gmail.com
-
--- A copyright notice.
--- copyright:           
-
-category:            Development
-
-description:         A quick and modular way to construct terminal interfaces.
-
-build-type:          Simple
-
--- Extra files to be distributed with the package, such as examples or a 
--- README.
-extra-source-files:  README.md
-
--- Constraint on the version of Cabal needed to build this package.
-cabal-version:       >=1.10
+name: quickterm
+version: 0.2.0.0
+cabal-version: >=1.10
+build-type: Simple
+license: GPL-3
+license-file: LICENSE
+maintainer: sgschlesinger@gmail.com,aka.bash0r@gmail.com
+homepage: https://github.com/SamuelSchlesinger/Quickterm
+synopsis: An interface for describing and executing terminal applications
+description:
+    A quick and modular way to construct terminal interfaces.
+category: Development
+author: Samuel Schlesinger, Nils 'bash0r' Jonsson
+extra-source-files:
+    README.md
 
 source-repository head
-  type: git
-  location: https://github.com/SamuelSchlesinger/Quickterm
-
+    type: git
+    location: https://github.com/SamuelSchlesinger/Quickterm
 
 library
-  -- Modules exported by the library.
-  exposed-modules: Quickterm
-  
-  -- Modules included in this library but not exported.
-  -- other-modules:       
-  
-  -- LANGUAGE extensions used by modules in this package.
-  -- other-extensions:    
-  
-  -- Other library packages from which modules are imported.
-  build-depends:       edit-distance, hashmap, base >=4.8 && <4.9
-  
-  -- Directories containing source files.
+  build-depends:       edit-distance, hashmap, base >=4.8 && <5
   hs-source-dirs:      src
-  
-  -- Base language which the package is written in.
   default-language:    Haskell2010
-  
+  exposed-modules:
+      System.Console.Quickterm
+      System.Console.Quickterm.DSL
+  other-modules:
+      System.Console.Quickterm.CanMarshall
+      System.Console.Quickterm.Deserializer
+      System.Console.Quickterm.Description
+      System.Console.Quickterm.Help
+      System.Console.Quickterm.Internal
+  build-depends:
+      edit-distance,
+      regex-base,
+      regex-tdfa,
+      uu-parsinglib,
+      base >=4.8 && <4.9
+  default-language: Haskell2010
+  hs-source-dirs: src/lib
+
+executable qt-demo
+    main-is: Main.hs
+    build-depends:
+        base >=4.8 && <4.9,
+        quickterm -any
+    default-language: Haskell2010
+    hs-source-dirs: src/demo
diff --git a/src/Quickterm.hs b/src/Quickterm.hs
deleted file mode 100644
--- a/src/Quickterm.hs
+++ /dev/null
@@ -1,144 +0,0 @@
-module Quickterm 
-    (
-        Quickterm(..)
-      , Options
-      , Name
-      , Args
-      , usage
-      , TerminalAction
-      , quickrun
-    )
-
-where
-
-import Text.EditDistance
-import Data.HashMap hiding (filter, map)
-
--- | I tend to call my applications by some name
---
-type Name = String
-
--- | With each of my endpoints for computation, I like to have some
---   description of their usage. 
-type Usage = String
-
--- | The sorts of actions which take place on the terminal are of
---   the form "cmd {<arg> | ("--" | "-") <opt-name> <opt-val>}".
---   The arguments are, in general, sequentially ordered.
-type Args = [String]
-
--- | The options, on the other hand, tend to be a mapping from some
---   set of names to some string.
-type Options = Map Name [String]
-
--- | The terminal action itself should take some arguments, some options,
---   and be able to produce some IO action dependent based on these.
---   The key here is that the TerminalAction is a pure function, taking
---   pure values and deterministically attempting some IO action based on
---   these. This is important to me in terms of designing and using programs. 
-type TerminalAction = Args -> Options -> IO ()
-
--- | In general, the applications I use have two sorts of endpoints:
---       
---   1) The application has a main command which takes arguments and options
---      and performs basically the same behavior, with some variation, based
---      on these inputs.
---
---   2) The application has a variety of sub-modules which have their own pretty
---      unique functionality and usage. I prefer these for two reasons: The first
---      is that, as the user, it separates the learning curve for one aspect of 
---      the program from some other one. The second is that it allows me as the
---      developer of such software to truly make modular systems and plug them in
---      and unplug them as I wish.
---
---   As I like this and I am developing this, I will then focus my efforts as such.
---   We shall call a program which contain submodules a Choice, whereas we shall
---   call a program which is simply a command to be run a Command. 
--- 
---   A Choice should simply have a Name, a list of Quickterms, and
---   a description of its Usage.
--- 
---   A Command may simply have a Name, a TerminalAction, and a description
---   of its Usage.
-data Quickterm = Choice Name [Quickterm] Usage
-               | Command Name TerminalAction Usage
-
---   Gets the name from an arbitrary Quickterm
--- 
-qtName :: Quickterm -> String
-qtName (Choice name _ _) = name
-qtName (Command name _ _) = name
-
--- | This function will generate the usage information and will be exposed at the top level.
-usage x = "usage: \n" ++ (usage' 0 x)
-
---   This function will gather the usage information, indented properly for the given
---   depth.
--- 
-usage' :: Int -> Quickterm  -> String
-usage' n (Choice name branches use) = (take n (repeat ' ')) ++ name ++ " " ++ use ++ "\n"
-                                    ++ (foldr (++) [] (map (usage' (n + 4)) branches))
-usage' n (Command name _ use) = (take n (repeat ' ')) ++ name ++ " " ++ use ++ "\n"
-
--- | This is a function which will take a top level program and attempt to run it,
---   printing out the usage information for the deepest Choice achieved if the attempt 
---   is failed, i.e we did not find a Command to run at all.
-quickrun :: [String] -> Quickterm -> IO ()
-quickrun x q = quickrun' args opts q where
-    (args, opts) = organizeInput x
-    quickrun' [] _ choice@(Choice _ _ _) = putStr (usage choice) -- No way to make a choice without input
-    quickrun' args opts (Command _ action _) = action args opts
-    quickrun' (nextbranch:args) opts choice@(Choice name branches use) = case findbranch nextbranch branches of
-                                                         Nothing -> whoopsy nextbranch 
-                                                                           (usage choice) 
-                                                                            branches
-                                                         Just branch -> quickrun' args opts branch
-
---   Finds a branch, given a name, in a list of Quickterms
--- 
-findbranch :: String -> [Quickterm] -> Maybe Quickterm
-findbranch _ [] = Nothing
-findbranch name ((choice@(Choice name' _ _)) : next) = if name == name' then Just choice else findbranch name next
-findbranch name ((command@(Command name' _ _)) : next) = if name == name' then Just command else findbranch name next
-
---   Finds the nearest branch, if there is one, and prints out "Did you mean <branch>?",
---   followed by the usage, which should be passed as the second argument.
-whoopsy :: String -> String -> [Quickterm] -> IO ()
-whoopsy name use list = do
-    case findnearestbranch name list of
-        Nothing -> putStr use
-        Just branch -> putStrLn ("Did you mean " ++ (qtName branch) ++ "?")
-
---   Finds the branch which most nearly matches the name given,
---   starting the lowest edit distance at 100000 cause if you
---   make your arguments long enough to get edit distances that high
---   you're wrong.
---   
-findnearestbranch :: String -> [Quickterm] -> Maybe Quickterm
-findnearestbranch name list = findnearestbranch' name Nothing 3 list where
-    findnearestbranch' :: String -> Maybe Quickterm -> Int -> [Quickterm] -> Maybe Quickterm
-    findnearestbranch' _ mqt _ [] = mqt
-    findnearestbranch' name nearest distance (branch:xs) = if distance > distance'
-        then findnearestbranch' name (Just branch) distance' xs
-        else findnearestbranch' name nearest distance xs where
-            distance' = levenshteinDistance defaultEditCosts name (qtName branch)
-
---   Options are of the form {-}<opt-name> {<arg>}, where the number of arguments to
---   the option is the number of dashes minus one.
---
---   The role of the rather nasty function below will be to extract the Options from
---   the list of strings and return the list of strings.
---   
-organizeInput :: [String] -> (Args, Options)
-organizeInput x = (args, opts) where
-    (args, opts) = organizeInput' x [] empty
-    organizeInput' :: [String] -> Args -> Options -> (Args, Options)
-    organizeInput' [] args opts = (reverse args, opts)
-    organizeInput' (('-':restopt):xs) args opts = organizeInput' rest args 
-                                                                (insert name vals opts) where
-        (name, rest, vals) = getOpt restopt xs [] 0
-        getOpt :: String -> [String] -> [String] -> Int -> (String, [String], [String])
-        getOpt ('-':more) xs args n = getOpt more xs args (n + 1)
-        getOpt name xs args n = (name, rest, vals) where
-            (vals, rest) = splitAt n xs
-    organizeInput' (x:xs) args opts = organizeInput' xs (x:args) opts
diff --git a/src/demo/Main.hs b/src/demo/Main.hs
new file mode 100644
--- /dev/null
+++ b/src/demo/Main.hs
@@ -0,0 +1,54 @@
+module Main where
+
+import           Control.Applicative
+import           Control.Monad
+
+import Data.List (lookup)
+
+import           System.Console.Quickterm
+
+
+main = qtMain myQtProgram
+
+myQtProgram = program
+  [ command "install" $ cmdInstall <$> flags
+    [ ("--bindir"  , Just "/default/bindir"  )
+    , ("--docdir"  , Just "/default/docdir"  )
+    , ("--datadir" , Just "/default/datadir" )
+    , ("--builddir", Just "/default/builddir")
+    , ("--foo"     , Nothing                 )
+    ]
+  , section "sandbox"
+    [ command_ "init"       cmdSandboxInit
+    , command_ "--help"     cmdSandboxHelp -- TODO: should be a built-in command
+    , command_ "--snapshot" cmdSandboxSnapshot
+    ]
+  ]
+
+-- |Simple application module.
+cmdSandboxSnapshot :: IO ()
+cmdSandboxSnapshot = do
+  putStrLn "Creating a snapshot..."
+  putStrLn "Done!"
+  putStrLn ""
+
+-- |Simple application module.
+cmdSandboxHelp :: IO ()
+cmdSandboxHelp = do
+  putStrLn "Help description for sandbox commands"
+  putStrLn ""
+
+-- |Simple application module.
+cmdSandboxInit :: IO ()
+cmdSandboxInit = do
+  putStrLn "Initializing a sandbox..."
+  putStrLn "Done!"
+  putStrLn ""
+
+-- |Application module with complex cmd-line parameters.
+cmdInstall :: [(String,String)] -> IO ()
+cmdInstall c = do
+  putStrLn "Starting installation with"
+  print c
+  putStrLn  "Installation done!"
+  putStrLn ""
diff --git a/src/lib/System/Console/Quickterm.hs b/src/lib/System/Console/Quickterm.hs
new file mode 100644
--- /dev/null
+++ b/src/lib/System/Console/Quickterm.hs
@@ -0,0 +1,145 @@
+module System.Console.Quickterm
+    ( module Export
+    , flag
+    , flag_
+    , flags
+    , command
+    , command_
+    , Description (..)
+    , section
+    , program
+    , quickterm
+    , qtMain
+    ) where
+
+import Control.Arrow (first)
+import           Control.Applicative
+import           Control.Monad
+
+import           Data.Char
+import           Data.Foldable                         (asum)
+import           Data.List                             (intercalate, sortBy)
+import           Data.Ord                              (comparing)
+
+import           System.Environment                    (getArgs)
+import           System.IO                             (hFlush, stdout)
+
+import           Text.EditDistance
+import           Text.Regex.Base                       hiding (empty)
+import           Text.Regex.TDFA                       hiding (empty)
+
+import           System.Console.Quickterm.CanMarshall  as Export
+import           System.Console.Quickterm.Description  as Export
+import           System.Console.Quickterm.Deserializer as Export
+import           System.Console.Quickterm.Help         as Export
+import           System.Console.Quickterm.Internal     as Export
+
+
+flag :: (IsDescription d, CanMarshall a) => d -> Quickterm a
+flag d = param >>= \n ->
+  let d' = toDescription d
+   in if   nameD d' == n
+      then param
+      else empty
+
+flag_ :: (IsDescription d) => d -> Quickterm ()
+flag_ d = param >>= \n' ->
+  let d' = toDescription d
+   in if nameD d' == n'
+      then pure ()
+      else empty
+
+flags :: (IsDescription d) => [(d,Maybe String)] -> Quickterm [(String,String)]
+flags ds = construct (first (nameD . toDescription) <$> defaults ds)
+                     (fst <$> ds)
+  where
+    defaults :: [(a,Maybe String)] -> [(a,String)]
+    defaults vs = case vs of
+      []            -> []
+      (a,Just b):vs -> (a,b):defaults vs
+      _         :vs -> defaults vs
+    construct :: (IsDescription d) => [(String,String)] -> [d] -> Quickterm [(String,String)]
+    construct ds fs =
+      foldr
+        (\(l,d) b -> (flag d >>= \v -> construct ds fs
+                             >>= \vs -> return ((l,v):vs)) <|> b)
+        (pure ds)
+        ((\d -> (nameD . toDescription $ d,d)) <$> fs)
+
+      -- case fs of
+      --[]     -> pure ds
+      --(f:fs) -> (flag f          >>= \f' ->
+      --           construct ds fs >>= \fs' ->
+      --           return ((nameD $ toDescription f,f'):fs')
+      --          ) <|> pure ds
+
+
+command :: (IsDescription d) => d -> Quickterm a -> Quickterm a
+command n c = section n [c]
+
+command_ :: (IsDescription d) => d -> a -> Quickterm a
+command_ n c = command n (pure c)
+
+-- |Creates a section Quickterm.
+section :: (IsDescription d) => d -> [Quickterm a] -> Quickterm a
+section d qs = Quickterm $ \i h pi as ->
+  let n     = nameD $ toDescription d
+      h' i  = h i ++ "\n" ++ indent n i
+      leven = levenshteinDistance defaultEditCosts
+   in case as of
+        []      -> qs >>= \m -> runQuickterm m (i + 10) h (n:pi) []
+        (a:as') -> qs >>= \m ->
+          runQuickterm m (i + leven n a) h' (n:pi) as'
+
+-- |Creates a program Quickterm.
+program :: [Quickterm a] -> Quickterm a
+program qs = Quickterm $ \i h pi as -> qs >>= \m -> runQuickterm m i h pi as
+
+fst5 :: (a,b,c,d,e) -> a
+fst5 (a,_,_,_,_) = a
+
+snd5 :: (a,b,c,d,e) -> b
+snd5 (_,b,_,_,_) = b
+
+verboseHelp :: [(IO (), Int, Help, [String], [String])] -> IO ()
+verboseHelp ts = do
+  let trav i ts = case ts of
+        []                 -> return ()
+        ((_,_,_,pi,_):ts') -> do
+          putStrLn ("[" ++ show i ++ "] " ++ (unwords . reverse) pi)
+          trav (i+1) ts'
+  when (not (null ts)) $ do
+    putStrLn "Did you mean one of these?"
+    trav 1 (take 9 ts)
+    putStr "[0 to quit]: "
+    hFlush stdout
+    l <- getLine
+    when (l =~ "(1|2|3|4|5|6|7|8|9)") $ do
+      let i = read l
+      when (i > 0 && i <= length ts) $
+        case ts !! (i - 1) of
+          (a,i,h,_,_) ->
+            if   i /= 0
+            then putStrLn (h 0)
+            else putStrLn "" >> a
+
+-- |Runs a quickterm application.
+quickterm :: Quickterm (IO ()) -> [String] -> IO ()
+quickterm qt as = case as of
+    "-v":as -> verbose True  as
+    as      -> verbose False as
+  where
+    ts = runQuickterm qt 0 (const "") []
+    verbose v as =
+      let ts' = ts as
+       in f v ts' . filter (\(_,i,_,_,rs) -> i == 0 && null rs) $ ts'
+    f v ts rs = case rs of
+      []  -> do
+        putStrLn "Could not match arguments to a command:"
+        putStrLn (">> " ++ unwords (if v then tail as else as) ++ " <<")
+        when v (verboseHelp ts)
+      [r] -> fst5 r
+      _   -> error "ambiguous call"
+
+qtMain :: Quickterm (IO ()) -> IO ()
+qtMain qt = quickterm qt =<< getArgs
diff --git a/src/lib/System/Console/Quickterm/CanMarshall.hs b/src/lib/System/Console/Quickterm/CanMarshall.hs
new file mode 100644
--- /dev/null
+++ b/src/lib/System/Console/Quickterm/CanMarshall.hs
@@ -0,0 +1,42 @@
+{-# LANGUAGE FlexibleInstances    #-}
+{-# LANGUAGE TypeSynonymInstances #-}
+
+module System.Console.Quickterm.CanMarshall
+    ( CanMarshall (..)
+    ) where
+
+import           Text.Regex.Base                       hiding (empty)
+import           Text.Regex.TDFA                       hiding (empty)
+
+import           System.Console.Quickterm.Deserializer
+import           System.Console.Quickterm.Help
+
+
+-- |Handles marshaling from a cmd-line argument to a Haskell data type.
+class CanMarshall a where
+  -- |A default value for the generic atomic operation 'param'.
+  defaultM     :: a
+  -- |A help description for the generic atomic operation 'param'.
+  helpU        :: a -> Int -> String
+  -- |A deserializer declaration for the generic atomic operation 'param'.
+  deserializer :: Deserializer a
+  -- |A conversion of a value to the predicted input.
+  asInput      :: a -> String
+
+instance CanMarshall Int where
+  defaultM = 0
+  helpU _ = indent "<Integer>"
+  deserializer = tryConvert $ \st ->
+    if   st =~ "((0|1|2|3|4|5|6|7|8|9)+)"
+    then [(read st,0)]
+    else [(0,length st * 2)]
+  asInput = show
+
+instance CanMarshall String where
+  defaultM = "<value>"
+  helpU _ = indent "<String>"
+  deserializer = tryConvert $ \st ->
+    if   st =~ "([^-]+)"
+    then [(st,0)]
+    else [("str",length st * 2)]
+  asInput = id
diff --git a/src/lib/System/Console/Quickterm/DSL.hs b/src/lib/System/Console/Quickterm/DSL.hs
new file mode 100644
--- /dev/null
+++ b/src/lib/System/Console/Quickterm/DSL.hs
@@ -0,0 +1,5 @@
+module System.Console.Quickterm.DSL
+    (
+    ) where
+
+import Text.ParserCombinators.UU
diff --git a/src/lib/System/Console/Quickterm/Description.hs b/src/lib/System/Console/Quickterm/Description.hs
new file mode 100644
--- /dev/null
+++ b/src/lib/System/Console/Quickterm/Description.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE FlexibleInstances    #-}
+{-# LANGUAGE TypeSynonymInstances #-}
+
+module System.Console.Quickterm.Description
+    ( Description   (..)
+    , IsDescription (..)
+    ) where
+
+import           System.Console.Quickterm.Help        (Help, indent)
+
+-- |A simple description for a section.
+data Description = Description
+  { -- |The name of a section.
+    nameD :: String
+  , -- |The description of a section.
+    longD :: Help
+  }
+
+class IsDescription f where
+  toDescription :: f -> Description
+
+instance IsDescription String where
+  toDescription s = Description s (indent s)
+
+instance IsDescription Description where
+  toDescription = id
diff --git a/src/lib/System/Console/Quickterm/Deserializer.hs b/src/lib/System/Console/Quickterm/Deserializer.hs
new file mode 100644
--- /dev/null
+++ b/src/lib/System/Console/Quickterm/Deserializer.hs
@@ -0,0 +1,36 @@
+module System.Console.Quickterm.Deserializer
+    ( Deserializer (..)
+    , tryConvert
+    ) where
+
+import Control.Applicative
+import Control.Monad
+
+
+-- |Deserializers are used in marshaling process of cmd-line parameters.
+newtype Deserializer a = Deserializer { deserialize :: [Char] -> Int -> [(a,[Char],Int)] }
+
+instance Functor Deserializer where
+  fmap f d = Deserializer $ \st p -> fmap (\(a,st',p') -> (f a,st',p')) (deserialize d st p)
+
+instance Applicative Deserializer where
+  pure a = Deserializer $ \st p -> [(a,st,p)]
+  f <*> d = Deserializer $ \st p -> deserialize f st p
+                         >>= \(g,st',p') -> deserialize d st' p'
+                         >>= \(a,st'',p'') -> return (g a,st'',p'')
+
+instance Alternative Deserializer where
+  empty = Deserializer (const (const empty))
+  d <|> h = Deserializer $ \st p -> deserialize d st p <|> deserialize h st p
+
+instance Monad Deserializer where
+  return = pure
+  d >>= f = Deserializer $ \st p -> deserialize d st p >>= \(d',st',p') -> deserialize (f d') st' p'
+
+instance MonadPlus Deserializer where
+  mzero = empty
+  mplus = (<|>)
+
+-- |A pure computation abstraction layer for the Deserializer.
+tryConvert :: (String -> [(a,Int)]) -> Deserializer a
+tryConvert f = Deserializer $ \st p -> (\(a,i) -> (a,[],p+i)) <$> f st
diff --git a/src/lib/System/Console/Quickterm/Help.hs b/src/lib/System/Console/Quickterm/Help.hs
new file mode 100644
--- /dev/null
+++ b/src/lib/System/Console/Quickterm/Help.hs
@@ -0,0 +1,25 @@
+module System.Console.Quickterm.Help
+    ( Help
+    , indent
+    ) where
+
+import Data.List (intercalate)
+
+
+type Help = Int -> String
+
+-- |A simple whitespace generator.
+ws :: Int -> String
+ws l = replicate (l*2) ' '
+
+-- |A whitespace manipulation function indenting the whole text block.
+indent :: String -> Int -> String
+indent a i = intercalate "\n" ((ws i ++) <$> splitLn a)
+
+-- |Splits a String to a [String] based on \n.
+splitLn :: String -> [String]
+splitLn = f []
+  where
+    f rs []        = [reverse rs]
+    f rs ('\n':ss) = reverse rs : f [] ss
+    f rs (s:ss)    = f (s:rs) ss
diff --git a/src/lib/System/Console/Quickterm/Internal.hs b/src/lib/System/Console/Quickterm/Internal.hs
new file mode 100644
--- /dev/null
+++ b/src/lib/System/Console/Quickterm/Internal.hs
@@ -0,0 +1,56 @@
+module System.Console.Quickterm.Internal
+    ( Quickterm (..)
+    , param
+    ) where
+
+import           System.Console.Quickterm.CanMarshall
+import           System.Console.Quickterm.Deserializer
+import           System.Console.Quickterm.Help
+
+import           Control.Applicative
+import           Control.Monad
+
+-- |Quickterm represents a non-deterministic calculation of a most predictable
+-- |command based on a breadth-first parsing strategy. The Quickterm is applied
+-- |to a [String] to achieve parsing of command line arguments.
+newtype Quickterm a = Quickterm
+  { runQuickterm :: Int
+                 -> Help
+                 -> [String]
+                 -> [String]
+                 -> [(a, Int, Help, [String], [String])]
+  }
+
+instance Functor Quickterm where
+  fmap f m = Quickterm $ \i h pi as ->
+    fmap (\(a,i',h',pi',as') -> (f a,i',h',pi',as'))
+         (runQuickterm m i h pi as)
+
+instance Applicative Quickterm where
+  pure a = Quickterm $ \i h pi as ->
+    pure (a,i,h,pi,as)
+  f <*> m = Quickterm $ \i h pi as -> join $
+    (\(g,i',h', pi',as') -> (\(a,i'',h'', pi'',as'') -> (g a,i'',h'',pi'',as''))
+      <$> runQuickterm m i' h' pi' as')
+      <$> runQuickterm f i h pi as
+
+instance Alternative Quickterm where
+  empty = Quickterm (const (const (const (const empty))))
+  m <|> n = Quickterm $ \i h pi as -> filter (\(_,i,_,_,_) -> i < 1000) $
+    runQuickterm m i h pi as <|> runQuickterm n i h pi as
+
+instance Monad Quickterm where
+  return = pure
+  m >>= f = Quickterm $ \i h pi as ->
+    runQuickterm m i h pi as >>= \(a,i',h',pi',as') ->
+      runQuickterm (f a) i' h' pi' as'
+
+instance MonadPlus Quickterm where
+  mzero = empty
+  mplus = (<|>)
+
+param :: (CanMarshall a) => Quickterm a
+param = Quickterm $ \i h pi as -> case as of
+      []      -> let d = defaultM in [(d,i+10,h,asInput d:pi,[])]
+      (a:as') -> deserialize deserializer a 0 >>= \(a, _, i') ->
+        return (a, i + i', h, asInput a:pi, as')
