diff --git a/Tools/ColorMap.hs b/Tools/ColorMap.hs
--- a/Tools/ColorMap.hs
+++ b/Tools/ColorMap.hs
@@ -18,7 +18,6 @@
 import qualified Data.ByteString.Char8 as S
 import qualified Data.Map as M
 
-
 data ColorMap = ColorMap {
   colorMaps :: M.Map S.ByteString ColorMap1 -- ^ Color scheme id -> Color map
 }
@@ -40,7 +39,7 @@
 -- | Compute color for a given name within the associated map.
 -- This function encapsulates the following rules:
 -- 
---  * If @color@ is a 6-digit hexadecimal value of the form '#FA34B7' then this is used as aan immediate
+--  * If @color@ is a 6-digit hexadecimal value of the form '#FA34B7' then this is used as an immediate
 --    RGB color,
 --
 --  * If @color@ is a color name from SVG1.1 specification (http://www.w3.org/TR/SVG11/types.html#ColorKeywords)
@@ -60,7 +59,7 @@
     g = fromIntegral $ unhex g2 + 16*unhex g1
     b = fromIntegral $ unhex b2 + 16*unhex b1
     unhex c | c >= '0' && c <= '9' = fromEnum c - fromEnum '0'
-            | c >= 'a' && c <= 'z' = fromEnum c - fromEnum 'a'
+            | c >= 'a' && c <= 'z' = 10 + fromEnum c - fromEnum 'a'
             | c >= 'A' && c <= 'Z' = 10 + fromEnum c - fromEnum 'A'
 readColor' cs = toSRGB `fmap` readColourName cs
     
diff --git a/Tools/StatePlot.hs b/Tools/StatePlot.hs
--- a/Tools/StatePlot.hs
+++ b/Tools/StatePlot.hs
@@ -19,11 +19,10 @@
 import Data.Colour
 import Data.Colour.SRGB
 import Data.Colour.Names
+import Data.Char (isSpace)
 
 import Tools.ColorMap
 
-import Debug.Trace
-
 data Event = Event { localTime :: !LocalTime, utcTime :: !UTCTime, track :: !S.ByteString, edge :: !Edge } deriving (Show)
 data Edge = Begin { color :: !S.ByteString } | End { color :: !S.ByteString } | Pulse { glyph :: !Glyph, color :: !S.ByteString } deriving (Show)
 
@@ -39,13 +38,14 @@
   where
     (ts, s') = parseTime s
     (track', arg0) = B.break (==' ') (B.tail s')
-    arg = if B.null arg0 then S.empty else repack (B.tail arg0)
+    arg = if B.null arg0 then S.empty else trim $ repack (B.tail arg0)
     edge = case (B.head track') of
       '>' -> Begin (if S.null arg then grayStr else arg)
       '<' -> End   (if S.null arg then S.empty else arg)
       '!' -> Pulse (GlyphText text) color
         where (color, text0) = S.break (==' ') arg
               text = S.tail text0
+    trim = fst . S.spanEnd isSpace
 
 repack = S.concat . B.toChunks
 
@@ -174,7 +174,7 @@
                        else (SmallTick, fromIntegral i*tickIntervalMs conf)) [0..]
 
       let legendW = case legendWidth conf of { Just w -> fromIntegral w; Nothing -> 0 }
-      let ms2x ms = legendW + 10 + ms / rangeMs * (w - 10)
+      let ms2x ms = legendW + 10 + ms / rangeMs * (w - 10 - legendW)
       let yStep = case barHeight conf of {
           BarHeightFixed _ -> (h-20) / fromIntegral (numTracks+1)
         ; BarHeightFill    -> (h-20) / fromIntegral numTracks
diff --git a/splot.cabal b/splot.cabal
--- a/splot.cabal
+++ b/splot.cabal
@@ -1,5 +1,5 @@
 Name: splot
-Version: 0.3.6
+Version: 0.3.7
 License: BSD3
 License-file: LICENSE
 Copyright: Eugene Kirpichov, 2010
