diff --git a/Tools/StatePlot.hs b/Tools/StatePlot.hs
--- a/Tools/StatePlot.hs
+++ b/Tools/StatePlot.hs
@@ -46,8 +46,6 @@
 diffToMillis t2 t1 = fromIntegral (truncate (1000000*d)) / 1000
  where d = diffUTCTime (localTimeToUTC utc t2) (localTimeToUTC utc t1)
 
-data TrackState = Phantom String | Active LocalTime String | Inactive deriving (Show)
-
 data RenderConfiguration = RenderConf {
         barHeight :: Double,
         tickIntervalMs :: Double,
@@ -67,20 +65,23 @@
     ticks = takeWhile (<rangeMs) $ iterate (+tickIntervalMs conf) 0
     tracks = sortBy (\as bs -> cmpTracks conf (head as) (head bs)) . groupBy ((==) `on` track) . sortBy (comparing track) $ events
 
-    initial = case phantomColor conf of { Nothing -> Inactive; Just c -> Phantom c }
+    maybeM :: (Monad m) => (a -> m b) -> Maybe a -> m ()
+    maybeM f Nothing  = return ()
+    maybeM f (Just x) = f x >> return ()
 
-    bars track = execWriter . (`evalStateT` initial) . mapM_ step $ track++[Event maxTime undefined End]
+    bars track = execWriter . (`evalStateT` Nothing) . mapM_ step . prepare $ track
       where
+        prepare  t = (capStart t) ++ t ++ (capEnd t)
+        capEnd   t = [Event maxTime undefined End]
+        capStart t = case (phantomColor conf, t) of
+          (Just c, Event _ _ End:_) -> [Event minTime undefined (Begin c)]
+          _                         -> []
+
         step (Event t _ edge) = do
-          s <- get
-          let barFrom t0 c0 = tell $ if (time2ms t - time2ms t0 < expireTimeMs conf) 
-                                     then [Bar (time2ms t0) (time2ms t) c0]
-                                     else [ExpiredBar (time2ms t0) (time2ms t0 + expireTimeMs conf) c0]
-          case (s,edge) of
-            (Active  t0 c0, _  ) -> barFrom t0      c0
-            (Phantom    c0, End) -> barFrom minTime c0
-            _                    -> return ()
-          put (case edge of { Begin c -> Active t c; End -> Inactive})
+          get >>= maybeM (\(t0,c0) -> tell $ if (time2ms t - time2ms t0 < expireTimeMs conf) 
+                                             then [Bar (time2ms t0) (time2ms t) c0]
+                                             else [ExpiredBar (time2ms t0) (time2ms t0 + expireTimeMs conf) c0])
+          put (case edge of { Begin c -> Just (t,c); End -> Nothing })
 
     render' (w,h) = do
       let ms2x ms = 10 + ms / rangeMs * (w - 10)
diff --git a/splot.cabal b/splot.cabal
--- a/splot.cabal
+++ b/splot.cabal
@@ -1,5 +1,5 @@
 Name: splot
-Version: 0.1.6
+Version: 0.1.7
 License: BSD3
 License-file: LICENSE
 Copyright: Eugene Kirpichov, 2010
@@ -8,7 +8,7 @@
 Synopsis: A tool for visualizing the lifecycle of many concurrent multi-staged processes.
 Description: A tool for visualizing the lifecycle of many concurrent multi-staged processes.
   Each process has a name, it starts at a point in time, ends at a point in time, and at some
-  points in time it changes colour.
+  points in time it changes colour. See presentation http://www.slideshare.net/jkff/two-visualization-tools .
 Homepage: http://www.haskell.org/haskellwiki/Splot
 Category: Graphics
 Cabal-Version: >= 1.6
