diff --git a/midi-music-box.cabal b/midi-music-box.cabal
--- a/midi-music-box.cabal
+++ b/midi-music-box.cabal
@@ -1,5 +1,5 @@
 Name:                midi-music-box
-Version:             0.0.1.2
+Version:             0.0.1.3
 Synopsis:            Convert MIDI file to music box punch tape
 Description:
   Convert MIDI file to music box punch tape for this kind of music box:
@@ -61,7 +61,7 @@
 Cabal-Version:       >=1.10
 
 Source-Repository this
-  Tag:         0.0.1.2
+  Tag:         0.0.1.3
   Type:        darcs
   Location:    https://hub.darcs.net/thielema/midi-music-box
 
@@ -74,11 +74,11 @@
   GHC-Options:         -Wall
   Build-Depends:
     diagrams-postscript >=1.3 && <1.6,
-    diagrams-lib >=1.3 && <1.5,
+    diagrams-lib >=1.3 && <1.7,
     midi >=0.2.2 && <0.3,
     event-list >=0.1.1 && <0.2,
-    optparse-applicative >=0.11 && <0.16,
-    containers >=0.4 && <0.7,
+    optparse-applicative >=0.11 && <0.20,
+    containers >=0.4 && <0.9,
     utility-ht >=0.0.10 && <0.1,
     base >=4.5 && <5
   Hs-Source-Dirs:      src
diff --git a/src/Main.hs b/src/Main.hs
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -158,6 +158,8 @@
    map (\(t, (dottyp,p)) -> (dottyp, (p,t))) $
    AbsEventList.toPairList $
    AbsEventList.mapTime ((/timeStep) . realToFrac) $
+   let ( pmin, (_, nmin)) = Map.findMin noteMap in
+   let (_pmax, (_, nmax)) = Map.findMax noteMap in
    AbsEventList.mapMaybe
       (\ev -> do
          (_c, (_v, p, True)) <- Query.noteExplicitOff ev
@@ -166,14 +168,12 @@
             case Map.lookup pz noteMap of
                Just (s, n) -> (if s then Valid else Semitone, n)
                Nothing ->
-                  let ( pmin, (_, nmin)) = Map.findMin noteMap
-                      (_pmax, (_, nmax)) = Map.findMax noteMap
-                  in  if pz < pmin
-                        then (TooLow,  nmin)
-                        else (TooHigh, nmax)) $
+                  if pz < pmin
+                     then (TooLow,  nmin)
+                     else (TooHigh, nmax)) $
    EventList.toAbsoluteEventList 0 $
-   MidiFile.mergeTracks typ $
-   map (MidiFile.secondsFromTicks division) tracks
+   MidiFile.secondsFromTicks division $
+   MidiFile.mergeTracks typ tracks
 
 
 musicScaleMap :: Map String MusicScale
