diff --git a/AUTHORS b/AUTHORS
new file mode 100644
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+This parser and associated example programs were created by:
+Michal J. Gajda 2010-2013
+In his free time, unencumbered by work duties.
diff --git a/Bio/PDB/Common.hs b/Bio/PDB/Common.hs
--- a/Bio/PDB/Common.hs
+++ b/Bio/PDB/Common.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE StandaloneDeriving, BangPatterns #-}
 module Bio.PDB.Common(String(..), Vector3(..))
 
 where
diff --git a/Bio/PDB/EventParser/FastParse.hs b/Bio/PDB/EventParser/FastParse.hs
--- a/Bio/PDB/EventParser/FastParse.hs
+++ b/Bio/PDB/EventParser/FastParse.hs
@@ -33,6 +33,7 @@
 digitValue !c = ord c - ord '0'
 
 {-# INLINE final #-}
+{-# ANN final "HLint: ignore Too strict if" #-}
 final :: Bool -> Double -> Maybe Double
 final !sign !f = if sign then Just (-f) else Just f
 
diff --git a/Bio/PDB/EventParser/HelixTypes.hs b/Bio/PDB/EventParser/HelixTypes.hs
--- a/Bio/PDB/EventParser/HelixTypes.hs
+++ b/Bio/PDB/EventParser/HelixTypes.hs
@@ -1,12 +1,12 @@
 -- | Module contains enumeration of helix types, and auxiliary functions
--- for converting these into numeric PDB CLASS code.
+-- for converting these into PDB CLASS codes.
 module Bio.PDB.EventParser.HelixTypes(HelixT, helix2code, code2helix)
 where
 {-| Enumeration of helix types
 
 PDB Class number in columns 39-40 for each type of helix in HELIX record:
 
- (1) Right-handed alpha (default)
+ (1) Right-handed alpha (default, most common)
 
  (2) Right-handed omega
 
@@ -40,7 +40,7 @@
               Polyproline
   deriving (Eq, Ord, Show, Read)
 
--- | helix2code converts a 'HelixT' enumeration into an PDB CLASS number.
+-- | helix2code converts a 'HelixT' enumeration into an PDB CLASS code.
 helix2code RightAlpha  =  1
 helix2code RightOmega  =  2
 helix2code RightPi     =  3
@@ -52,7 +52,7 @@
 helix2code Ribbon2_7   =  9
 helix2code Polyproline = 10
 
--- | helix2code converts an PDB CLASS number into a 'HelixT' enumeration.
+-- | helix2code converts an PDB CLASS code into a 'HelixT' enumeration.
 code2helix  1 = RightAlpha
 code2helix  2 = RightOmega
 code2helix  3 = RightPi
diff --git a/Bio/PDB/EventParser/PDBEventParser.hs b/Bio/PDB/EventParser/PDBEventParser.hs
--- a/Bio/PDB/EventParser/PDBEventParser.hs
+++ b/Bio/PDB/EventParser/PDBEventParser.hs
@@ -76,7 +76,7 @@
       a | "ENDMDL" `BS.isPrefixOf` a -> cont1 $! return [ENDMDL] 
       a | "END"    `BS.isPrefixOf` a -> cont1 $! return [END]
       -- common error in treatment of TER - omitting rest of the record
-      "TER"                          -> cont1 $! return [TER { num = (-1), resname = "", chain = ' ', resid = (-1), insCode = ' ' }]
+      "TER"                          -> cont1 $! return [TER { num = -1, resname = "", chain = ' ', resid = -1, insCode = ' ' }]
       -- proper TER
       a | "TER"    `BS.isPrefixOf` a -> cont1 $! parseTER    line line_no
       a | "MASTER" `BS.isPrefixOf` a -> cont1 $! parseMASTER line line_no
@@ -140,7 +140,7 @@
 -- | Parses a strict ByteString 'contents' named 'fname' and performs 'action'
 -- on events given by parsing chunks, returning accumulated results. Accumulator
 -- is primed by 'acc'.
-parsePDBRecords fname contents action acc = parsePDBLines fname contents 0 action acc
+parsePDBRecords fname contents = parsePDBLines fname contents 0
 
 -- | Checks whether line was ignored as unknown record type
 ignoreLine (PDBIgnoredLine _) = False
diff --git a/Bio/PDB/EventParser/PDBEventPrinter.hs b/Bio/PDB/EventParser/PDBEventPrinter.hs
--- a/Bio/PDB/EventParser/PDBEventPrinter.hs
+++ b/Bio/PDB/EventParser/PDBEventPrinter.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings, PatternGuards #-}
+{-# LANGUAGE OverloadedStrings, PatternGuards, CPP #-}
 module Bio.PDB.EventParser.PDBEventPrinter(print, isPrintable)
 
 where
@@ -9,17 +9,19 @@
 import System.IO(Handle, IO, stderr)
 import qualified Data.ByteString.Char8 as BS
 import Data.String(IsString)
-import Control.Monad(mapM, return)
+import Control.Monad(mapM_, return)
 
-import Bio.PDB.EventParser.PDBEvents
+import           Bio.PDB.EventParser.PDBEvents
 import qualified Bio.PDB.EventParser.ExperimentalMethods as ExperimentalMethods
+#ifdef HAVE_TEXT_FORMAT
 import qualified Data.ByteString.Lazy as L
-import Data.Text.Lazy.Encoding(encodeUtf8)
-import Data.Text.Encoding     (decodeUtf8)
+import           Data.Text.Lazy.Encoding(encodeUtf8)
+import           Data.Text.Encoding     (decodeUtf8)
 import qualified Data.Text.Lazy as LT
-import Data.Text.Lazy.Builder as B
+import           Data.Text.Lazy.Builder as B
 import qualified Data.Text.Format as F
 import qualified Data.Text.Buildable as BD
+#endif
 
 -- | Prints a PDBEvent to a filehandle.
 print :: Handle -> PDBEvent -> IO ()
@@ -37,18 +39,30 @@
                     elt       = e,
                     charge    = ch,
                     hetatm    = isHet
-                  } = do L.hPutStr handle . encodeUtf8 $ F.format "{}{} {}{}{} {}{}{}   {}{}{}{}{}       {}{}{}\n" args
+                  } =
+#ifndef HAVE_TEXT_FORMAT
+    hPrintf handle
+           "%6s%5d  %-3s%c%-3s %c%4d%c   %8.3f%8.3f%8.3f%6.2f%6.2f       %-4s%-2s%-2s\n"
+                   recname
+                   num (BS.unpack atype) al (BS.unpack rtype) c rid rins
+                   x y z occ bf
+                   (BS.unpack sid) (BS.unpack e) (BS.unpack ch)
   where
+    recname :: Prelude.String
+    recname = if isHet then "HETATM" else "ATOM  "
+#else
+    L.hPutStr handle . encodeUtf8 $ F.format "{}{} {}{}{} {}{}{}   {}{}{}{}{}       {}{}{}\n" args
+  where
     -- ra justifies a ByteString to the right
     ra i = F.right i ' ' . decodeUtf8
     -- la justifies anything else (floating point or integer number) to the left
     la i = F.left  i ' '
     args = (recname, la 5 num, specfmt 4 3 atype,
-            conv al, ra 3 $ rtype,
+            conv al, ra 3 rtype,
             conv c, la 4 rid,
             conv rins,
             ca x, ca y, ca z, pa occ, pa bf,
-            ra 4 $ sid, ra 2 $ e, ra 2 $ ch)
+            ra 4 sid, ra 2 e, ra 2 ch)
     ca f = la 8 $ F.fixed 3 f -- align coordinate float
     pa f = la 6 $ F.fixed 2 f -- align property float
     recname = fromText $ if isHet then "HETATM" else "ATOM  "
@@ -56,6 +70,7 @@
     conv x = fromString [x]
     -- specfmt mimics erratic alignment of PDB atom types: up to three characters are justified left, after prefixing by single space.
     specfmt i j a = B.fromLazyText . LT.justifyRight i ' ' . LT.justifyLeft j ' ' . B.toLazyText . fromText . decodeUtf8 $ a
+#endif
 
 -- TODO: Note that this ANISOU code will be buggy for 4-letter atom codes that happen (rarely.)
 print handle ANISOU { no       = n, 
@@ -110,7 +125,7 @@
 print handle END    = hPrintf handle "END\n"
 print handle ENDMDL = hPrintf handle "ENDMDL\n"
 print handle CONECT { atoms=ats } = do hPrintf handle "CONECT"
-                                       mapM (hPrintf handle "%5d") ats
+                                       mapM_ (hPrintf handle "%5d") ats
                                        hPrintf handle "\n"
 print handle TER    { num     = n    ,
                       resname = r    ,
@@ -129,15 +144,14 @@
                       numMaster = nmaster,
                       numConect = ncon,
                       numSeqres = nseq } = do hPrintf handle "MASTER    %5d    0" nr
-                                              mapM (hPrintf handle "%5d")
-                                                   [nhet, nhel, nsheet,
-                                                    nturn, nsite, nxform, nats,
-                                                    nmaster, ncon, nseq]
+                                              mapM_ (hPrintf handle "%5d")
+                                                    [nhet, nhel, nsheet,
+                                                     nturn, nsite, nxform, nats,
+                                                     nmaster, ncon, nseq]
                                               hPrintf handle "\n"
 print handle REMARK { num  = n,
-                      text = t } = do mapM (hPrintf handle "REMARK %4d %-80s\n" n .
-                                            BS.unpack) t
-                                      return ()
+                      text = t } = mapM_ (hPrintf handle "REMARK %4d %-80s\n" n .
+                                          BS.unpack) t
 {-              KEYWDS { continuation  :: !Int,
                          aList         :: ![String] }    |
                 AUTHOR { continuation  :: !Int,
@@ -149,11 +163,10 @@
 print handle AUTHOR { continuation = c,
                       aList        = l } = printList handle "AUTHOR" "," c l
 print handle EXPDTA { continuation = c,
-                      expMethods   = e } = do mapM (hPrintf handle "EXPDTA   %c%-80s\n"
-                                                            (showContinuation c) .
-                                                    BS.unpack .
-                                                    ExperimentalMethods.showExpMethod) e
-                                              return ()
+                      expMethods   = e } = mapM_ (hPrintf handle "EXPDTA   %c%-80s\n"
+                                                          (showContinuation c) .
+                                                  BS.unpack .
+                                                  ExperimentalMethods.showExpMethod) e
 print handle TITLE { continuation = c,
                      title        = t } = hPrintf handle "TITLE   %c%-80s\n"
                                                          (showContinuation c)
@@ -162,8 +175,8 @@
                       chain   = ch,
                       num     = n,
                       resList = l } = do hPrintf handle "SEQRES %3d %c %4d   " sn ch n
-                                         mapM (hPrintf handle "%3s " .
-                                               BS.unpack) l
+                                         mapM_ (hPrintf handle "%3s " .
+                                                BS.unpack) l
                                          -- TODO: split when longer than X residues
                                          hPrintf handle "\n"
 print handle COMPND { cont   = c,
@@ -200,11 +213,11 @@
     header :: String
     header  = if aJRNL then "JRNL        " else "REMARK    1 "
     [contd] = if c > 0 then show c else " "
-    printJRNL ((k,v):cs) = do hPrintf handle "%12s%4s %c %s\n"
-                                      (BS.unpack header)
-                                      (BS.unpack k)
-                                      contd
-                                      (BS.unpack v)
+    printJRNL ((k,v):cs) = hPrintf handle "%12s%4s %c %s\n"
+                                   (BS.unpack header)
+                                   (BS.unpack k)
+                                   contd
+                                   (BS.unpack v)
 
 -- print errors:
 print handle (PDBParseError c r s) = hPrintf stderr "ERROR: In line %d column %d: %s" c r
@@ -268,11 +281,11 @@
 printMatrix :: Handle -> BS.ByteString -> Int -> [Vector3] -> [Double] -> IO ()
 printMatrix handle ident n []         []     = return ()
 printMatrix handle ident n (vec:vecs) (f:fs) = do hPrintf handle "%5s%c    " (BS.unpack ident) cn
-                                                  mapM printEntry [a, b, c]
+                                                  mapM_ printEntry [a, b, c]
                                                   hPrintf handle "      %9.5f\n" f
                                                   printMatrix handle ident (n+1) vecs fs
   where [cn] = show n
         printEntry :: Double -> IO ()
-        printEntry f = hPrintf handle "%10.6f" f
+        printEntry = hPrintf handle "%10.6f"
         Vector3 a b c = vec
 
diff --git a/Bio/PDB/EventParser/PDBParsingAbstractions.hs b/Bio/PDB/EventParser/PDBParsingAbstractions.hs
--- a/Bio/PDB/EventParser/PDBParsingAbstractions.hs
+++ b/Bio/PDB/EventParser/PDBParsingAbstractions.hs
@@ -278,9 +278,9 @@
 --
 -- (3) input
 convertColumns :: [String -> ParsedField] -> [Int] -> String -> [ParsedField]
-convertColumns convs cols s = map convert (zip convs content)
+convertColumns convs cols s = zipWith convert convs content
   where
-    convert (conv, s) = conv s
+    convert conv s = conv s
     content = splitByColumns s cols
 
 {-# INLINE findColumnErrors #-}
diff --git a/Bio/PDB/EventParser/ParseATOM.hs b/Bio/PDB/EventParser/ParseATOM.hs
--- a/Bio/PDB/EventParser/ParseATOM.hs
+++ b/Bio/PDB/EventParser/ParseATOM.hs
@@ -124,7 +124,7 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 --{-# SPECIALIZE parseATOM :: Bool -> String -> Int -> IO [PDBEvent] #-}
 parseATOM :: (Monad m) => String -> Int -> m [PDBEvent]
-parseATOM line line_no = return $ if errs == []
+parseATOM line line_no = return $ if null errs
                                     then [result]
                                     else errs
   where
@@ -234,7 +234,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseANISOU :: (Monad m) => String -> Int -> m [PDBEvent]
-parseANISOU line line_no = return $ if errs == [] then result `seq` [result] else errs
+parseANISOU line line_no = return $ if null errs then result `seq` [result] else errs
   where
     -- parse
     (fields, errs) = parseFields anisouFields line line_no
diff --git a/Bio/PDB/EventParser/ParseCAVEAT.hs b/Bio/PDB/EventParser/ParseCAVEAT.hs
--- a/Bio/PDB/EventParser/ParseCAVEAT.hs
+++ b/Bio/PDB/EventParser/ParseCAVEAT.hs
@@ -41,7 +41,7 @@
 --
 parseCAVEAT ::  (Monad m) => String -> Int -> m [PDBEvent]
 -- Result is a monad action returning a list of 'PDBEvent's.
-parseCAVEAT line line_no = return $ if errs == []
+parseCAVEAT line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseCISPEP.hs b/Bio/PDB/EventParser/ParseCISPEP.hs
--- a/Bio/PDB/EventParser/ParseCISPEP.hs
+++ b/Bio/PDB/EventParser/ParseCISPEP.hs
@@ -62,7 +62,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseCISPEP ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseCISPEP line line_no = return $ if errs == []
+parseCISPEP line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseCONECT.hs b/Bio/PDB/EventParser/ParseCONECT.hs
--- a/Bio/PDB/EventParser/ParseCONECT.hs
+++ b/Bio/PDB/EventParser/ParseCONECT.hs
@@ -44,7 +44,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseCONECT :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseCONECT line line_no = return $ if errs == []
+parseCONECT line line_no = return $ if null errs
                                       then [result]
                                       else errs
   where
diff --git a/Bio/PDB/EventParser/ParseCRYST1.hs b/Bio/PDB/EventParser/ParseCRYST1.hs
--- a/Bio/PDB/EventParser/ParseCRYST1.hs
+++ b/Bio/PDB/EventParser/ParseCRYST1.hs
@@ -48,9 +48,9 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 {-# SPECIALIZE parseCRYST1 :: BS.ByteString -> Int -> IO [PDBEvent] #-}
 parseCRYST1 :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseCRYST1 line line_no = return $ if errs == []
+parseCRYST1 line line_no = return $ if null errs
                                       then [result]
-                                      else errs--}
+                                      else errs
   where
     -- parse
     (fields, errs) = parseFields crystFields line line_no
diff --git a/Bio/PDB/EventParser/ParseDBREF.hs b/Bio/PDB/EventParser/ParseDBREF.hs
--- a/Bio/PDB/EventParser/ParseDBREF.hs
+++ b/Bio/PDB/EventParser/ParseDBREF.hs
@@ -82,7 +82,7 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 {-# SPECIALIZE parseDBREF :: BS.ByteString -> Int -> IO [PDBEvent] #-}
 parseDBREF :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseDBREF line line_no = return $ if errs == []
+parseDBREF line line_no = return $ if null errs
                                      then [result]
                                      else errs
   where
@@ -200,7 +200,7 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 {-# SPECIALIZE parseDBREF12 :: (BS.ByteString, BS.ByteString) -> Int -> IO [PDBEvent] #-}
 parseDBREF12 :: (Monad m) => (BS.ByteString, BS.ByteString) -> Int -> m [PDBEvent]
-parseDBREF12 (!line1, !line2) !line_no = return $ if errs == []
+parseDBREF12 (!line1, !line2) !line_no = return $ if null errs
                                                     then [result]
                                                     else errs
   where
diff --git a/Bio/PDB/EventParser/ParseFORMUL.hs b/Bio/PDB/EventParser/ParseFORMUL.hs
--- a/Bio/PDB/EventParser/ParseFORMUL.hs
+++ b/Bio/PDB/EventParser/ParseFORMUL.hs
@@ -44,7 +44,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseFORMUL ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseFORMUL line line_no = return $ if errs == []
+parseFORMUL line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseHEADER.hs b/Bio/PDB/EventParser/ParseHEADER.hs
--- a/Bio/PDB/EventParser/ParseHEADER.hs
+++ b/Bio/PDB/EventParser/ParseHEADER.hs
@@ -37,7 +37,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseHEADER :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseHEADER line line_no = return $ if errs == [] then [result] else errs
+parseHEADER line line_no = return $ if null errs then [result] else errs
   where
     -- parse
     (fields, errs) = parseFields headerFields line line_no
diff --git a/Bio/PDB/EventParser/ParseHELIX.hs b/Bio/PDB/EventParser/ParseHELIX.hs
--- a/Bio/PDB/EventParser/ParseHELIX.hs
+++ b/Bio/PDB/EventParser/ParseHELIX.hs
@@ -73,7 +73,7 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseHELIX :: (Monad m) => String -> Int -> m [PDBEvent]
 parseHELIX line line_no = --return [Test $ BS.pack $ show $ ((length helixFields)::Int)]
-  return $ if errs == []
+  return $ if null errs
                                       then [result]
                                       else errs
   where
diff --git a/Bio/PDB/EventParser/ParseHET.hs b/Bio/PDB/EventParser/ParseHET.hs
--- a/Bio/PDB/EventParser/ParseHET.hs
+++ b/Bio/PDB/EventParser/ParseHET.hs
@@ -48,7 +48,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseHET ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseHET line line_no = return $ if errs == []
+parseHET line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseHETNAM.hs b/Bio/PDB/EventParser/ParseHETNAM.hs
--- a/Bio/PDB/EventParser/ParseHETNAM.hs
+++ b/Bio/PDB/EventParser/ParseHETNAM.hs
@@ -42,7 +42,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseHETNAM :: (Monad m) => Bool -> String -> Int -> m [PDBEvent]
-parseHETNAM isNameNotSynonym line line_no = return $ if errs == []
+parseHETNAM isNameNotSynonym line line_no = return $ if null errs
                                                        then [result]
                                                        else errs
   where
diff --git a/Bio/PDB/EventParser/ParseHYDBND.hs b/Bio/PDB/EventParser/ParseHYDBND.hs
--- a/Bio/PDB/EventParser/ParseHYDBND.hs
+++ b/Bio/PDB/EventParser/ParseHYDBND.hs
@@ -77,7 +77,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseHYDBND :: (Monad m) => String -> Int -> m [PDBEvent]
-parseHYDBND line line_no = return $ if errs == []
+parseHYDBND line line_no = return $ if null errs
                                    then [result]
                                    else errs -- return $ [PDBParseError 0 0 $ BS.pack $ show $ Prelude.length fields]
   where
diff --git a/Bio/PDB/EventParser/ParseIntRecord.hs b/Bio/PDB/EventParser/ParseIntRecord.hs
--- a/Bio/PDB/EventParser/ParseIntRecord.hs
+++ b/Bio/PDB/EventParser/ParseIntRecord.hs
@@ -37,7 +37,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseIntRecord :: (Monad m) => (Int -> PDBEvent) ->  String -> Int -> m [PDBEvent]
-parseIntRecord cons line line_no = return $ if errs == []
+parseIntRecord cons line line_no = return $ if null errs
                                               then [result]
                                               else errs
   where
diff --git a/Bio/PDB/EventParser/ParseJRNL.hs b/Bio/PDB/EventParser/ParseJRNL.hs
--- a/Bio/PDB/EventParser/ParseJRNL.hs
+++ b/Bio/PDB/EventParser/ParseJRNL.hs
@@ -47,7 +47,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseJournalRef :: (Monad m) => Bool -> BS.ByteString -> Int -> m [PDBEvent]
-parseJournalRef isFirst line line_no = return $ if errs == []
+parseJournalRef isFirst line line_no = return $ if null errs
                                                   then [result]
                                                   else errs
   where
diff --git a/Bio/PDB/EventParser/ParseLINK.hs b/Bio/PDB/EventParser/ParseLINK.hs
--- a/Bio/PDB/EventParser/ParseLINK.hs
+++ b/Bio/PDB/EventParser/ParseLINK.hs
@@ -68,12 +68,12 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseLINK ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseLINK line line_no = return $ if errs == []
+parseLINK line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
     -- parse
-    errs = if fErrs == [] then fgErrs else fErrs
+    errs = if null fErrs then fgErrs else fErrs
     (fields, fErrs) = parseFields linkFields line line_no
     [fRec, _,
      fAtName1, fAltLoc1, fResname1, _, fChain1, fResnum1, fInsCode1, _,
diff --git a/Bio/PDB/EventParser/ParseListRecord.hs b/Bio/PDB/EventParser/ParseListRecord.hs
--- a/Bio/PDB/EventParser/ParseListRecord.hs
+++ b/Bio/PDB/EventParser/ParseListRecord.hs
@@ -53,7 +53,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseListRecord :: (Monad m) =>(Int -> [String] -> PDBEvent)-> Char-> String-> Int-> m [PDBEvent]
-parseListRecord cons sep line line_no = return $ if errs == []
+parseListRecord cons sep line line_no = return $ if null errs
                                                    then [result]
                                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseMASTER.hs b/Bio/PDB/EventParser/ParseMASTER.hs
--- a/Bio/PDB/EventParser/ParseMASTER.hs
+++ b/Bio/PDB/EventParser/ParseMASTER.hs
@@ -62,7 +62,7 @@
 -- (2) input line number
 --
 -- Result is a mionad action returning a list of 'PDBEvent's.
-parseMASTER line line_no = return $ if errs == []
+parseMASTER line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseMODRES.hs b/Bio/PDB/EventParser/ParseMODRES.hs
--- a/Bio/PDB/EventParser/ParseMODRES.hs
+++ b/Bio/PDB/EventParser/ParseMODRES.hs
@@ -50,7 +50,7 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 {-# SPECIALIZE parseMODRES :: BS.ByteString -> Int -> IO [PDBEvent] #-}
 parseMODRES :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseMODRES line line_no = return $ if errs == []
+parseMODRES line line_no = return $ if null errs
                                      then [result]
                                      else errs
   where
@@ -62,7 +62,7 @@
     IFStr  stdres  = fStdRes
     IFStr  comment = fComment
 
-    errs = if fErrs == [] then fgErrs else fErrs
+    errs = if null fErrs then fgErrs else fErrs
     fgRes     = fgResidue True "modified" 15 fModRes fChain fSeqNum fInsCode
     fgErrs    = liftFgErrs line_no [fgRes]
     Right res = fgRes
diff --git a/Bio/PDB/EventParser/ParseMatrixRecord.hs b/Bio/PDB/EventParser/ParseMatrixRecord.hs
--- a/Bio/PDB/EventParser/ParseMatrixRecord.hs
+++ b/Bio/PDB/EventParser/ParseMatrixRecord.hs
@@ -52,7 +52,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseMatrixRecord :: (Monad m) =>(Int -> Bool -> Int -> [Vector3] -> [Double] -> PDBEvent)-> String-> Int-> m [PDBEvent]
-parseMatrixRecord cons line line_no = return $ if errs == []
+parseMatrixRecord cons line line_no = return $ if null errs
                                                  then [result]
                                                  else errs
   where
diff --git a/Bio/PDB/EventParser/ParseObsoleting.hs b/Bio/PDB/EventParser/ParseObsoleting.hs
--- a/Bio/PDB/EventParser/ParseObsoleting.hs
+++ b/Bio/PDB/EventParser/ParseObsoleting.hs
@@ -59,7 +59,7 @@
 -- (3) input line number
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
-parseObsoleting cons line line_no = return $ if errs == []
+parseObsoleting cons line line_no = return $ if null errs
                                                then [result]
                                                else errs
   where
diff --git a/Bio/PDB/EventParser/ParseREMARK.hs b/Bio/PDB/EventParser/ParseREMARK.hs
--- a/Bio/PDB/EventParser/ParseREMARK.hs
+++ b/Bio/PDB/EventParser/ParseREMARK.hs
@@ -43,7 +43,7 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseREMARK :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
 parseREMARK line line_no = 
-    if errs == []
+    if null errs
       then (if (num == 1)                             && 
                not (BS.all (==' ') text)              &&
                not ("REFERENCE" `BS.isPrefixOf` text)
diff --git a/Bio/PDB/EventParser/ParseREVDAT.hs b/Bio/PDB/EventParser/ParseREVDAT.hs
--- a/Bio/PDB/EventParser/ParseREVDAT.hs
+++ b/Bio/PDB/EventParser/ParseREVDAT.hs
@@ -75,7 +75,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseREVDAT :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseREVDAT line line_no = return $ if errs == []
+parseREVDAT line line_no = return $ if null errs
                                       then [result]
                                       else errs
   where
diff --git a/Bio/PDB/EventParser/ParseSEQADV.hs b/Bio/PDB/EventParser/ParseSEQADV.hs
--- a/Bio/PDB/EventParser/ParseSEQADV.hs
+++ b/Bio/PDB/EventParser/ParseSEQADV.hs
@@ -59,7 +59,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseSEQADV :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseSEQADV line line_no = return $ if errs == []
+parseSEQADV line line_no = return $ if null errs
                                      then [result]
                                      else errs
   where
@@ -77,7 +77,7 @@
                    IFNone       -> Nothing
     IFStr  comment   = fComment
 
-    errs      = if fErrs == [] then fgErrs else fErrs
+    errs      = if null fErrs then fgErrs else fErrs
     fgRes     = maybeFgResidue False "modified residue" 15 fResname fChain fSeqNum fInsCode
     fgErrs    = liftFgErrs line_no [fgRes]
     Right res = fgRes
diff --git a/Bio/PDB/EventParser/ParseSEQRES.hs b/Bio/PDB/EventParser/ParseSEQRES.hs
--- a/Bio/PDB/EventParser/ParseSEQRES.hs
+++ b/Bio/PDB/EventParser/ParseSEQRES.hs
@@ -69,7 +69,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseSEQRES :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseSEQRES line line_no = return $ if errs == []
+parseSEQRES line line_no = return $ if null errs
                                       then [result]
                                       else errs
   where
diff --git a/Bio/PDB/EventParser/ParseSHEET.hs b/Bio/PDB/EventParser/ParseSHEET.hs
--- a/Bio/PDB/EventParser/ParseSHEET.hs
+++ b/Bio/PDB/EventParser/ParseSHEET.hs
@@ -100,7 +100,7 @@
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseSHEET ::  (Monad m) => String -> Int -> m [PDBEvent]
 parseSHEET line line_no = --return [Test $ BS.pack $ show $ ((length helixFields)::Int)]
-  return $ if errs == []
+  return $ if null errs
                                       then [result]
                                       else errs
   where
diff --git a/Bio/PDB/EventParser/ParseSITE.hs b/Bio/PDB/EventParser/ParseSITE.hs
--- a/Bio/PDB/EventParser/ParseSITE.hs
+++ b/Bio/PDB/EventParser/ParseSITE.hs
@@ -94,12 +94,12 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseSITE ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseSITE line line_no = return $ if errs == []
+parseSITE line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
     -- parse
-    errs = if fErrs == [] then fgErrs else fErrs
+    errs = if null fErrs then fgErrs else fErrs
     (fields, fErrs) = parseFields siteFields line line_no
     [fRec, _, fSerial, _, fSiteId, _, fNumRes, _,
      fResname1, _, fChain1, fResnum1, fInsCode1, _,
diff --git a/Bio/PDB/EventParser/ParseSLTBRG.hs b/Bio/PDB/EventParser/ParseSLTBRG.hs
--- a/Bio/PDB/EventParser/ParseSLTBRG.hs
+++ b/Bio/PDB/EventParser/ParseSLTBRG.hs
@@ -65,7 +65,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseSLTBRG ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseSLTBRG line line_no = return $ if errs == []
+parseSLTBRG line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseSPLIT.hs b/Bio/PDB/EventParser/ParseSPLIT.hs
--- a/Bio/PDB/EventParser/ParseSPLIT.hs
+++ b/Bio/PDB/EventParser/ParseSPLIT.hs
@@ -49,7 +49,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseSPLIT :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseSPLIT line line_no = return $ if errs == []
+parseSPLIT line line_no = return $ if null errs
                                      then [result]
                                      else errs
   where
diff --git a/Bio/PDB/EventParser/ParseSSBOND.hs b/Bio/PDB/EventParser/ParseSSBOND.hs
--- a/Bio/PDB/EventParser/ParseSSBOND.hs
+++ b/Bio/PDB/EventParser/ParseSSBOND.hs
@@ -63,7 +63,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseSSBOND ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseSSBOND line line_no = return $ if errs == []
+parseSSBOND line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseSpecListRecord.hs b/Bio/PDB/EventParser/ParseSpecListRecord.hs
--- a/Bio/PDB/EventParser/ParseSpecListRecord.hs
+++ b/Bio/PDB/EventParser/ParseSpecListRecord.hs
@@ -57,7 +57,7 @@
     checkEntry :: [String] -> [PDBEvent]
     checkEntry [_, _] = []
     checkEntry [   _] = []
-    checkEntry entry  = [PDBParseError line_no 11 {- column where speclist begins -} $
+    checkEntry entry  = [PDBParseError line_no 11 {- column where speclist begins -}
                          ("Cannot parse specification list fragment: " `BS.append`
                           ( BS.pack . show $ entry))]
 
diff --git a/Bio/PDB/EventParser/ParseTER.hs b/Bio/PDB/EventParser/ParseTER.hs
--- a/Bio/PDB/EventParser/ParseTER.hs
+++ b/Bio/PDB/EventParser/ParseTER.hs
@@ -46,7 +46,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseTER ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseTER line line_no = return $ if errs == []
+parseTER line line_no = return $ if null errs
                                    then [result]
                                    else errs
   where
diff --git a/Bio/PDB/EventParser/ParseTITLE.hs b/Bio/PDB/EventParser/ParseTITLE.hs
--- a/Bio/PDB/EventParser/ParseTITLE.hs
+++ b/Bio/PDB/EventParser/ParseTITLE.hs
@@ -36,7 +36,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseTITLE :: (Monad m) => BS.ByteString -> Int -> m [PDBEvent]
-parseTITLE line line_no = return $ if errs == []
+parseTITLE line line_no = return $ if null errs
                                      then [result]
                                      else errs
   where
diff --git a/Bio/PDB/EventParser/ParseTVECT.hs b/Bio/PDB/EventParser/ParseTVECT.hs
--- a/Bio/PDB/EventParser/ParseTVECT.hs
+++ b/Bio/PDB/EventParser/ParseTVECT.hs
@@ -44,7 +44,7 @@
 --
 -- Result is a monad action returning a list of 'PDBEvent's.
 parseTVECT ::  (Monad m) => String -> Int -> m [PDBEvent]
-parseTVECT line line_no = return $ if errs == []
+parseTVECT line line_no = return $ if null errs
                                      then [result]
                                      else errs
   where
diff --git a/Bio/PDB/IO.hs b/Bio/PDB/IO.hs
--- a/Bio/PDB/IO.hs
+++ b/Bio/PDB/IO.hs
@@ -4,7 +4,7 @@
 
 import qualified Control.Exception(catch)
 import Control.Exception.Base(SomeException)
-import System.IO hiding(writeFile)
+import System.IO hiding(writeFile, FilePath)
 import Prelude hiding(String,writeFile)
 import Bio.PDB.EventParser.PDBParsingAbstractions
 import Bio.PDB.Structure.List as L
@@ -25,26 +25,30 @@
 -- Until I get a newer version of Control.DeepSeq:
 force x = x `deepseq` x
 
-parse :: String -> IO (Maybe Bio.PDB.Structure.Structure)
-parse filename = do input <- Bio.PDB.IO.OpenAnyFile.readFile $ BS.unpack filename
-                    (do (structure, errs) <- return $ Bio.PDB.StructureBuilder.parse filename input
-                        mapM_ (showError filename) (L.toList errs)
-                        structure `deepseq` return $ Just $ structure
-                      `Control.Exception.catch`
-                     (exceptionHandler filename))
+-- | Parse a .pdb file and return `Bio.PDB.Structure.Structure`.
+parse :: FilePath -> IO (Maybe Bio.PDB.Structure.Structure)
+parse filename = do input <- Bio.PDB.IO.OpenAnyFile.readFile filename
+                    do (structure, errs) <- return $ Bio.PDB.StructureBuilder.parse filename input
+                       mapM_ (showError filename) (L.toList errs)
+                       structure `deepseq` return $ Just structure
+                     `Control.Exception.catch`
+                     exceptionHandler filename
 
-exceptionHandler :: String -> SomeException -> IO (Maybe a)
-exceptionHandler filename e = do printError $ [filename, ":", BS.pack $ show e]
+-- | Default exception handler that for `IO (Maybe a)` just prints nice error message to stderr, and returns Nothing
+exceptionHandler :: FilePath -> SomeException -> IO (Maybe a)
+exceptionHandler filename e = do printError [BS.pack filename, ":", BS.pack $ show e]
                                  return Nothing
 
+-- | Prints a catenated list of ByteStrings to stderr. (Convenience function.)
 printError msg = BS.hPutStrLn System.IO.stderr $ BS.concat msg
 
+-- | Show error message from `PDBParser`.
 showError filename (PDBParseError line_no col_no msg) =
-  printError $ [filename, ":", BS.pack $ show line_no, ":", BS.pack $ show col_no, "\t", msg]
+  printError [BS.pack filename, ":", BS.pack $ show line_no, ":", BS.pack $ show col_no, "\t", msg]
 showError filename (PDBIgnoredLine line)              =
-  printError $ [filename, ": IGNORED ", line]
+  printError [BS.pack filename, ": IGNORED ", line]
 
--- | Write structure to a .pdb file. (NOT YET IMPLEMENTED)
-write :: Bio.PDB.Structure.Structure -> String -> IO ()
-write structure fname = writeFile (BS.unpack fname) $ \h -> PDBSP.write h structure
+-- | Write structure to a .pdb file.
+write :: Bio.PDB.Structure.Structure -> FilePath -> IO ()
+write structure fname = writeFile fname $ \h -> PDBSP.write h structure
 
diff --git a/Bio/PDB/IO/OpenAnyFile.hs b/Bio/PDB/IO/OpenAnyFile.hs
--- a/Bio/PDB/IO/OpenAnyFile.hs
+++ b/Bio/PDB/IO/OpenAnyFile.hs
@@ -11,6 +11,7 @@
 import System.Directory (doesFileExist, getPermissions, Permissions(..))
 import System.IO.Error  (userError, IOError)
 import System.IO        (withFile, IOMode(..))
+import Control.Monad    (void)
 -- if we have zlib:
 import qualified Codec.Compression.GZip as GZip
 import qualified Data.ByteString.Lazy   as BSL
@@ -21,7 +22,7 @@
 
 -- if we have MMap:
 #ifdef HAVE_MMAP
-import System.IO.Posix.MMap(unsafeMMapFile)
+import System.IO.MMap   (mmapFileByteString)
 #endif
 
 -- otherwise:
@@ -35,8 +36,8 @@
                         throwNotFound fname
 
 readFile' fname = do content <- simpleRead fname
-                     let r = (let codec = getCodec fname content
-                              in BS.concat $ BSL.toChunks $ codec $ BSL.fromChunks [content])
+                     let r = let codec = getCodec fname content
+                             in BS.concat $ BSL.toChunks $ codec $ BSL.fromChunks [content]
                      return r
 
 throwNotFound :: String -> IO a
@@ -45,7 +46,7 @@
 getCodec fname c | (".gz" `BS.isSuffixOf` BS.pack fname) ||
                    (".Z"  `BS.isSuffixOf` BS.pack fname) = GZip.decompressWith (gzipParams c)
 --getCodec fname c | (".bz2" `BS.isSuffixOf` (BS.pack fname)) = BZip.decompressWith (bzipParams c) -- DOESN'T WORK!!!
-getCodec fname c | otherwise                             = id
+getCodec fname c                                         = id
 
 gzipParams c = GZip.DecompressParams GZip.defaultWindowBits (fromIntegral (BS.length c * 5))
 #ifndef OLD_ZLIB
@@ -62,13 +63,12 @@
                         else return False
 
 #ifndef HAVE_MMAP
-simpleRead fname = BS.readFile fname
+simpleRead       = BS.readFile 
 #else
-simpleRead fname = unsafeMMapFile fname `Exc.catch` \e -> do reportError (e :: IOError)
-                                                             BS.readFile fname
+simpleRead fname = mmapFileByteString fname Nothing `Exc.catch` \e -> do reportError (e :: IOError) -- cannot mmap
+                                                                         BS.readFile fname
   where
     reportError e = do putStrLn $ concat [show e, "while trying to mmap('", fname, "')"]
 #endif
 
-writeFile fname writer = do withFile fname WriteMode $ writer 
-                            return ()
+writeFile fname writer = void $ withFile fname WriteMode writer 
diff --git a/Bio/PDB/InstantiateIterable.hs b/Bio/PDB/InstantiateIterable.hs
deleted file mode 100644
--- a/Bio/PDB/InstantiateIterable.hs
+++ /dev/null
@@ -1,68 +0,0 @@
-{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, NoMonomorphismRestriction #-}
-module Bio.PDB.InstantiateIterable(Iterable(..)  ,
-                                   gen_iterable  ,
-                                   self_iterable ,
-                                   trans_iterable) where
-
-import qualified Bio.PDB.Structure.List as L
-import Language.Haskell.TH.Syntax
-import Control.Monad.Identity(runIdentity,foldM)
-import Data.List(foldl')
-
-class Iterable a b where
-  imapM   :: (Monad m) => (b -> m b) -> a -> m a
-  imap    ::              (b ->   b) -> a ->   a
-  imap f e = runIdentity $ imapM (\b -> return $ f b) e
-  ifoldM  :: (Monad m) => (c -> b -> m c) -> c -> a -> m c
-  ifoldr  ::              (b -> c ->   c) -> c -> a ->   c
-  ifoldl  ::              (c -> b ->   c) -> c -> a ->   c
-  ifoldl' ::              (c -> b ->   c) -> c -> a ->   c
-  ilength :: b -> a -> Int -- NOTE: b is 'dummy' type argument to satisfy Iterable a b constraint
-
--- | Generates a direct instance of iterable between $typA and $typB with
---   given names of getter and setter, so that:
---   $getter :: $typA -> $typB 
---   $setter :: $typB -> $typA -> $typA
-gen_iterable typA typB getter setter = 
-  [d| instance Iterable $(typA) $(typB) where
-        imapM f a =
-          do b' <- L.mapM f ( $(getter) a)
-             return $ $(setter) a b'
-        ifoldM  f e a  = do r <- L.foldM f e ( $(getter) a)
-                            return r
-        ifoldr  f e a = L.foldr  f e ( $(getter) a)
-        ifoldl  f e a = L.foldl  f e ( $(getter) a)
-        ifoldl' f e a = L.foldl' f e ( $(getter) a) 
-        ilength   d a = L.length ( $(getter) a)
-    |]
-
--- | Generates convenience function for iterating over a single object.
-self_iterable typA = 
-  [d| instance Iterable $(typA) $(typA) where
-        imapM f a     = f a 
-        ifoldM  f e a = f e a
-        ifoldr  f e a = f a e
-        ifoldl  f e a = f e a 
-        ifoldl' f e a = f e a
-        ilength   d a = 1
-    |]
---self_iterable typA = gen_iterable typA typA [e| id |] [e| L.singleton |]
-
--- This works:
---   ilength     a = L.length     ( $(getter) a)
-
--- | Generates a transitive instance of `Iterable` between $typA and $typC,
---   assuming existence of `Iterable` $typA $typB, and `Iterable` $typB $typC.
-trans_iterable typA typB typC = 
-  [d| instance Iterable $(typA) $(typC) where
-        imapM   f a   = (imapM   :: (Monad m) => ( $(typB) -> m $(typB) ) -> $(typA)   -> m $(typA) ) (imapM f) a 
-        imap    f a   = (imap    ::              ( $(typB) ->   $(typB) ) -> $(typA)   ->   $(typA) ) (imap  f) a 
-        ifoldM  f e a = (ifoldM  :: (Monad m) => (c -> $(typB)   -> m c) -> c   -> $(typA)   -> m c       ) (ifoldM  f) e a 
-        ifoldr  f e a = (ifoldr  ::              ($(typB) -> c   ->   c) -> c   -> $(typA)   ->   c       ) (\bb cc -> ifoldr  f cc bb) e a
-        ifoldl  f e a = (ifoldl  ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (ifoldl  f) e a
-        ifoldl' f e a = (ifoldl' ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (ifoldl' f) e a
-        ilength _   a = (ifoldl' ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (\a b-> a + ilength (undefined :: $(typC)) b) 0 a
-    |]
--- How to make this work:
---       ilength     a = (ifoldl' ::              (Int -> $(typB) -> Int) -> Int -> $(typA)   ->   Int     ) (\i b -> i+(ilength :: Iterable $(typB) $(typC) => $(typB) -> Int) b) 0 a
-
diff --git a/Bio/PDB/Iterable.hs b/Bio/PDB/Iterable.hs
--- a/Bio/PDB/Iterable.hs
+++ b/Bio/PDB/Iterable.hs
@@ -1,20 +1,23 @@
 {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, UndecidableInstances, OverlappingInstances, TemplateHaskell, FlexibleContexts #-}
+-- | Instances of Iterable class.
 module Bio.PDB.Iterable(Iterable(..)) where
 
+import Data.Iterable
+import Data.Iterable.Instantiate
+import Data.Iterable.Instantiate.Vector
+import Data.Vector
 import Bio.PDB.Structure.List as L
 import Bio.PDB.Structure 
 import Control.Monad.Identity
 import Control.Monad(foldM)
 
-import Bio.PDB.InstantiateIterable
-
-$(gen_iterable [t| Structure |] [t| Model   |] [e| models   |] [e| (\s m -> s { models   = m }) |] )
+$(gen_vector_iterable [t| Structure |] [t| Model   |] [e| models   |] [e| (\s m -> s { models   = m }) |] )
 
-$(gen_iterable [t| Model     |] [t| Chain   |] [e| chains   |] [e| (\s m -> s { chains   = m }) |] )
+$(gen_vector_iterable [t| Model     |] [t| Chain   |] [e| chains   |] [e| (\s m -> s { chains   = m }) |] )
 
-$(gen_iterable [t| Chain     |] [t| Residue |] [e| residues |] [e| (\s m -> s { residues = m }) |] )
+$(gen_vector_iterable [t| Chain     |] [t| Residue |] [e| residues |] [e| (\s m -> s { residues = m }) |] )
 
-$(gen_iterable [t| Residue   |] [t| Atom    |] [e| atoms    |] [e| (\s m -> s { atoms    = m }) |] )
+$(gen_vector_iterable [t| Residue   |] [t| Atom    |] [e| atoms    |] [e| (\s m -> s { atoms    = m }) |] )
 
 $(self_iterable [t| Structure |] )
 $(self_iterable [t| Model     |] )
diff --git a/Bio/PDB/Structure.hs b/Bio/PDB/Structure.hs
--- a/Bio/PDB/Structure.hs
+++ b/Bio/PDB/Structure.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE BangPatterns, DisambiguateRecordFields #-}
+{-# LANGUAGE DisambiguateRecordFields #-}
 module Bio.PDB.Structure(String,
                          vdot, vnorm, vproj, vperpend, vperpends, vdihedral, (*|), (|*),
                          Structure(..), Model(..), Chain(..), Residue(..), Atom(..))
diff --git a/Bio/PDB/Structure/Elements.hs b/Bio/PDB/Structure/Elements.hs
--- a/Bio/PDB/Structure/Elements.hs
+++ b/Bio/PDB/Structure/Elements.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings, BangPatterns #-}
+{-# LANGUAGE OverloadedStrings #-}
 module Bio.PDB.Structure.Elements(Element(..),
                                   -- Finding element for a given atom
                                   assignElement,
diff --git a/Bio/PDB/Structure/List.hs b/Bio/PDB/Structure/List.hs
--- a/Bio/PDB/Structure/List.hs
+++ b/Bio/PDB/Structure/List.hs
@@ -70,7 +70,7 @@
                                   when (i < 0) $ fail "Negative STRef"
                                   let j = i + 1
                                       l = M.length v
-                                  v' <- if (j > l)
+                                  v' <- if j > l
                                           then do nV <- M.grow v j
                                                   writeSTRef vs nV
                                                   return nV
diff --git a/Bio/PDB/Structure/Vector.hs b/Bio/PDB/Structure/Vector.hs
--- a/Bio/PDB/Structure/Vector.hs
+++ b/Bio/PDB/Structure/Vector.hs
@@ -1,6 +1,6 @@
 {-# LANGUAGE NoMonomorphismRestriction, BangPatterns #-}
-module Bio.PDB.Structure.Vector(Vec3D(..),
-                                unpackVec3D,
+module Bio.PDB.Structure.Vector(Vector3(..),
+                                unpackVector3,
                                 vnormalise, vdot, (*|), (|*),
                                 vzip, vmap,
                                 vnorm, vproj, vperpend, vperpends, vdihedral) where
@@ -10,54 +10,51 @@
 import Data.List(foldl')
 import Test.QuickCheck
 
--- ^ This module wraps 3D vector operations, and adds missing ones. Also hides a "Vector" class
-
--- | Defines type alias for position and translation vectors in PDB structures.
-type Vec3D = Vector3
+-- ^ This module wraps 3D vector operations, and adds missing ones.
 
 -- | Unpacks an abstract 3D vector into a triple of Doubles.
-unpackVec3D :: Vec3D -> (Double, Double, Double)
-unpackVec3D (Vector3 x y z) = (x, y, z)
+unpackVector3 :: Vector3 -> (Double, Double, Double)
+unpackVector3 (Vector3 x y z) = (x, y, z)
 
 -- | Maps an operation that modifies a Double onto a 3D vector.
 {-# INLINE vmap #-}
-vmap :: (Double -> Double) -> Vec3D -> Vec3D
+vmap :: (Double -> Double) -> Vector3 -> Vector3
 vmap = C.vmap
 
 -- | Maps an operation on a pair of Doubles onto a pair of 3D vectors
 --   coordinatewise.
-vzip :: (Double -> Double -> Double) -> Vec3D -> Vec3D -> Vec3D
+vzip :: (Double -> Double -> Double) -> Vector3 -> Vector3 -> Vector3
 vzip = C.vzip
 
 -- | Normalises to a unit vector in the same direction as input.
 {-# INLINE vnormalise #-}
-vnormalise :: Vec3D -> Vec3D
+vnormalise :: Vector3 -> Vector3
 vnormalise = C.vnormalise 
 
 -- | Computes a dot product of two 3D vectors.
 {-# INLINE vdot #-}
-vdot :: Vec3D -> Vec3D -> Double
+vdot :: Vector3 -> Vector3 -> Double
 vdot = C.vdot
 
 {-# INLINE vnorm #-}
 -- | 2-norm of a vector (also called a magnitude or length.)
-vnorm :: Vec3D -> Double
+vnorm :: Vector3 -> Double
 vnorm = C.vmag
 
 {-# INLINE vdihedral #-}
 -- | Compute dihedral between three bond vectors using spherical angle formula.
-vdihedral :: Vec3D -> Vec3D -> Vec3D -> Double
-vdihedral !a !b !c = (atan2 (vnorm b * (a `vdot`  (b `vcross` c)))
-                            ((a `vcross` b) `vdot` (b `vcross` c)) )
+vdihedral :: Vector3 -> Vector3 -> Vector3 -> Double
+vdihedral !a !b !c = atan2 (vnorm b * (a `vdot`  (b `vcross` c)))
+                           ((a `vcross` b) `vdot` (b `vcross` c))
 
 -- | Scalar product. (`*` indicates side on which one can put a scalar.)
 {-# INLINE (*|) #-}
-(*|) :: Double -> Vec3D  -> Vec3D
+(*|) :: Double -> Vector3  -> Vector3
 (*|) = (C.*|)
 
 -- | Scalar product. (`*` indicates side on which one can put a scalar.)
 {-# INLINE (|*) #-}
-(|*) :: Vec3D  -> Double -> Vec3D
+(|*) :: Vector3  -> Double -> Vector3
 (|*) = (C.|*)
 
 {-# INLINE vproj #-}
diff --git a/Bio/PDB/StructureBuilder.hs b/Bio/PDB/StructureBuilder.hs
--- a/Bio/PDB/StructureBuilder.hs
+++ b/Bio/PDB/StructureBuilder.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE BangPatterns, DisambiguateRecordFields, MultiParamTypeClasses, NamedFieldPuns, FlexibleContexts, OverloadedStrings, PatternGuards, RankNTypes #-}
+{-# LANGUAGE BangPatterns, DisambiguateRecordFields, MultiParamTypeClasses, NamedFieldPuns, FlexibleContexts, OverloadedStrings, RankNTypes #-}
 {-# LANGUAGE RecordWildCards #-} -- for convenient debugging
 {-# OPTIONS_GHC -fspec-constr-count=2 #-}
 module Bio.PDB.StructureBuilder(parse)
@@ -11,6 +11,7 @@
 import Control.Monad.State.Strict      as State 
 import Control.Monad(when)
 import Data.STRef                      as STRef
+import Data.Maybe(isNothing, isJust)
 
 import Bio.PDB.EventParser.PDBEvents(PDBEvent(..), RESID(..))
 import qualified Bio.PDB.EventParser.PDBEventParser(parsePDBRecords)
@@ -28,14 +29,14 @@
 parsePDBRec :: String -> String -> (() -> PDBEvent -> ParsingMonad t ()) -> () -> ParsingMonad t ()
 parsePDBRec = Bio.PDB.EventParser.PDBEventParser.parsePDBRecords
 
---parse :: (State.MonadState BState m) => String -> String -> m (Structure, [PDBEvent])
 -- | Given filename, and contents, parses a whole PDB file, returning a monadic action
 -- | with a tuple of (Structure, [PDBEvent]), where the list of events contains all
 -- | parsing or construction errors.
+--parse :: (State.MonadState BState m) => FilePath -> String -> m (Structure, [PDBEvent])
 parse fname contents = ST.runST $ do initial <- initializeState
                                      (s, e)  <- State.evalStateT parsing initial
-                                     return $! (s :: Structure, e :: L.List PDBEvent)
-  where parsing = do parsePDBRec fname contents (\() !ev -> parseStep ev) ()
+                                     return (s :: Structure, e :: L.List PDBEvent)
+  where parsing = do parsePDBRec (BS.pack fname) contents (\() !ev -> parseStep ev) ()
                      closeStructure
                      s  <- State.gets currentStructure
                      e  <- State.gets errors
@@ -52,7 +53,7 @@
                          modelContents     :: L.TempList  s Chain,
                          structureContents :: L.TempList  s Model,
                          errors            :: L.TempList  s PDBEvent,
-                         line_no           :: STRef.STRef s Int
+                         lineNo           :: STRef.STRef s Int
                        }
 
 -- | Initial state of the structure record builder.
@@ -63,16 +64,16 @@
                      s  <- L.initialNew 1
                      e  <- L.initialNew 100
                      l  <- STRef.newSTRef 1
-                     return $ BState { currentResidue    = Nothing,
-                                       currentModel      = Nothing,
-                                       currentChain      = Nothing,
-                                       currentStructure  = Structure { models = L.empty },
-                                       residueContents   = r,
-                                       chainContents     = c,
-                                       modelContents     = m,
-                                       structureContents = s,
-                                       errors            = e,
-                                       line_no           = l }
+                     return BState { currentResidue    = Nothing,
+                                     currentModel      = Nothing,
+                                     currentChain      = Nothing,
+                                     currentStructure  = Structure { models = L.empty },
+                                     residueContents   = r,
+                                     chainContents     = c,
+                                     modelContents     = m,
+                                     structureContents = s,
+                                     errors            = e,
+                                     lineNo           = l }
 -- | Checks that a residue with a given identification tuple is current,
 -- | or if not, then closes previous residue (if present),
 -- | and marks a new ,,current'' residue in a state of builder.
@@ -109,8 +110,8 @@
   where
     chainChanged Nothing                               = True
     chainChanged (Just (Chain { chainId = oldChain })) = oldChain /= name
-    createChain l state = state { currentChain = Just $! Chain { chainId  = name,
-                                                                 residues = L.empty },
+    createChain l state = state { currentChain = Just Chain { chainId  = name,
+                                                              residues = L.empty },
                                   chainContents = l }
 
 
@@ -120,18 +121,18 @@
 --       [Otherwise one needs to report an error!]
 checkModel :: ParsingMonad t ()
 checkModel = do curModel <- State.gets currentModel
-                when (curModel == Nothing) $ openModel 1
+                when (isNothing curModel) $ openModel 1
 -- | Closes construction of a current residue and appends this residue to a current chain. (Monadic action.)
 --closeResidue :: State.State BState ()
 
 closeResidue :: ParsingMonad t ()
 closeResidue = do r <- State.gets currentResidue
-                  when (r /= Nothing) $ do let Just res = r
-                                           rc  <- State.gets residueContents
-                                           rf  <- L.finalize rc
-                                           cc  <- State.gets chainContents
-                                           cc' <- L.add cc $ res { Bio.PDB.Structure.atoms = rf }
-                                           State.modify clearResidue
+                  when (isJust r) $ do let Just res = r
+                                       rc  <- State.gets residueContents
+                                       rf  <- L.finalize rc
+                                       cc  <- State.gets chainContents
+                                       cc' <- L.add cc $ res { Bio.PDB.Structure.atoms = rf }
+                                       State.modify clearResidue
   where
     clearResidue st = st { currentResidue = Nothing }
 
@@ -142,21 +143,21 @@
 closeChain = do closeResidue
                 c  <- State.gets currentChain
                 ac <- State.gets chainContents
-                when (c /= Nothing) $ do l   <- State.gets chainContents
-                                         l'  <- L.finalize l
-                                         let Just ch = c
-                                             ch' = ch { Bio.PDB.Structure.residues = l' }
-                                         m   <- State.gets currentModel
-                                         when (m == Nothing) $ do mli <- State.gets structureContents
-                                                                  i <- L.tempLength mli
-                                                                  openModel i
-                                                                  addError ["Trying to close chain when currentChain is ",
-                                                                            BS.pack . show $ ch,
-                                                                            " and currentModel is ",
-                                                                            BS.pack . show $ m]
-                                         ml  <- State.gets modelContents
-                                         ml' <- L.add ml ch'
-                                         State.modify clearChain
+                when (isJust c) $ do l   <- State.gets chainContents
+                                     l'  <- L.finalize l
+                                     let Just ch = c
+                                         ch' = ch { Bio.PDB.Structure.residues = l' }
+                                     m   <- State.gets currentModel
+                                     when (isNothing m) $ do mli <- State.gets structureContents
+                                                             i <- L.tempLength mli
+                                                             openModel i
+                                                             addError ["Trying to close chain when currentChain is ",
+                                                                       BS.pack . show $ ch,
+                                                                       " and currentModel is ",
+                                                                       BS.pack . show $ m]
+                                     ml  <- State.gets modelContents
+                                     ml' <- L.add ml ch'
+                                     State.modify clearChain
   where
     clearChain st = st { currentChain = Nothing }
 
@@ -165,11 +166,12 @@
 -- TODO: forgot about line/column number passing!
 addError :: [String] -> ParsingMonad t ()
 addError msg = do e  <- State.gets errors
-                  lnref <- State.gets line_no
+                  lnref <- State.gets lineNo
                   ln <- lift $ STRef.readSTRef lnref
                   lift $ STRef.modifySTRef lnref (+1)
                   L.add e $ anError ln
-  where anError ln = PDBParseError ln 0 $ BS.concat msg
+  where
+    anError ln = PDBParseError ln 0 $ BS.concat msg
 
 -- | Finalizes construction of current model
 closeModel :: ParsingMonad t ()
@@ -199,14 +201,14 @@
                structureContents = undefined }
 
 nextLine :: ParsingMonad t ()
-nextLine = do lnref <- State.gets line_no
+nextLine = do lnref <- State.gets lineNo
               lift $ STRef.modifySTRef lnref (+1)
 
 -- | Performs a match on a single PDBEvent and performs relevant change to a BState of structure builder.
 --parseStep   :: (State.MonadState BState m) => PDBEvent -> m ()
 parseStep pe@(PDBParseError l _ _) = do e  <- State.gets errors
                                         L.add e pe 
-                                        lnref <- State.gets line_no
+                                        lnref <- State.gets lineNo
                                         lift $ STRef.writeSTRef lnref l
 parseStep (ATOM { no        = atSer,      -- :: !Int,
                   atomtype  = atType,     -- :: !String,
diff --git a/Bio/PDB/Util/MissingInstances.hs b/Bio/PDB/Util/MissingInstances.hs
--- a/Bio/PDB/Util/MissingInstances.hs
+++ b/Bio/PDB/Util/MissingInstances.hs
@@ -1,128 +1,15 @@
 {-# LANGUAGE CPP #-}
 
--- | This module contains instances of `NFData` for Data.ByteString
---   and `Params` before text-format 0.3.0.8.
+-- | This module contains instances of `NFData` for Data.ByteString.
 module Bio.PDB.Util.MissingInstances() where
 
 import Prelude()
 import qualified Data.ByteString as BS
 import Control.DeepSeq
 
-#ifdef DEFINE_PARAMS_INSTANCES
-import Data.Text.Buildable
-import Data.Text.Format.Types
-import Data.Text.Lazy.Builder
-import Data.Text.Format.Params(Params(..))
-#endif
-
-
 #ifdef DEFINE_NFDATA_INSTANCE
 -- I use strict version of BS.ByteString so default implementation should do
 -- | Nothing needs to be done in NFData instance for stricty `BS.ByteString`.
 instance NFData BS.ByteString where
 #endif
 
-#ifdef DEFINE_PARAMS_INSTANCES
-
--- | Adds instances of Params for tuples of more than ten Buildables.
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k)
-    => Params (a,b,c,d,e,f,g,h,i,j,k) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m, Buildable n)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m,n) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m, build n]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m, build n, build o]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
-          Buildable p)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m, build n, build o,
-         build p]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
-          Buildable p, Buildable r)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m, build n, build o,
-         build p, build r]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
-          Buildable p, Buildable r, Buildable s)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m, build n, build o,
-         build p, build r, build s]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
-          Buildable p, Buildable r, Buildable s, Buildable t)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m, build n, build o,
-         build p, build r, build s, build t]
-
-instance (Buildable a, Buildable b, Buildable c, Buildable d, Buildable e,
-          Buildable f, Buildable g, Buildable h, Buildable i, Buildable j,
-          Buildable k, Buildable l, Buildable m, Buildable n, Buildable o,
-          Buildable p, Buildable r, Buildable s, Buildable t, Buildable u)
-    => Params (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u) where
-    buildParams (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u) =
-        [build a, build b, build c, build d, build e,
-         build f, build g, build h, build i, build j,
-         build k, build l, build m, build n, build o,
-         build p, build r, build s, build t, build u]
-
-#endif
diff --git a/INSTALL b/INSTALL
new file mode 100644
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,32 @@
+Please use either `cabal install` or `runhaskell Setup configure --user`
+to install or configure the package. This is because `runhaskell Setup`
+defaults to use global package database, and thus may give spurious error
+messages, when the dependencies are installed in user's package database.
+
+For a fresh GHC install on Ubuntu, you may first need to `apt-get install
+zlib1g-dev` to get zlib header files.
+
+Troubleshooting:
+1. `runhaskell Setup configure` tells that dependencies are missing,
+even though I have them installed!
+
+Use `runhaskell Setup configure --user` or see Cabal FAQ:
+http://www.haskell.org/cabal/FAQ.html#runghc-setup-complains-of-missing-packages
+
+2. double-conversion dependency breaks the linking process with error:
+
+This is known GHC bug that may appear in FreeBSD and Windows:
+http://ghc.haskell.org/trac/ghc/ticket/5289
+
+Workaround is to switch off the flag that makes printing faster:
+Append `-f-have-double-conversion` to `cabal install` or `runhaskell Setup
+configure` arguments.
+
+3. [Windows] Cannot get `unix` dependency.
+
+Please switch off using bytestring-mmap package by appending flag
+`-f-have-mmap` to `cabal install` or `runhaskell Setup configure` arguments.
+
+TODO: try to change *.cabal file so it is done automatically.
+
+4. 
diff --git a/README.md b/README.md
new file mode 100644
--- /dev/null
+++ b/README.md
@@ -0,0 +1,13 @@
+hPDB
+====
+Haskell PDB file format parser.
+
+[![Build Status](https://api.travis-ci.org/mgajda/hPDB.png?branch=master)](https://www.travis-ci.org/mgajda/hPDB)
+
+Protein Data Bank file format is a most popular format for holding biomolecule data.
+
+This is a very fast parser: below 7s for the largest entry in PDB - 1HTQ which is over 70MB - as compared with 11s of RASMOL 2.7.5, or 2m15s of BioPython with Python 2.6 interpreter.
+
+It is aimed to not only deliver event-based interface, but also a high-level data structure for manipulating data in spirit of BioPython's PDB parser. 
+
+Details on official releases are on [Hackage](http://hackage.haskell.org/package/hPDB).
diff --git a/Setup.hs b/Setup.hs
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,4 +1,18 @@
 #! /usr/bin/env runhaskell
 
+module Main(main) where
+
 import Distribution.Simple
-main = defaultMain
+import System.Environment
+import Control.Monad(when)
+import Data.List(isPrefixOf)
+
+-- Defaults to installing in --user package database.
+isPkgDbOpts arg = ("--package-db" `isPrefixOf` arg  ) || (arg `elem` ["--user", "--global"])
+haveNotPkgDbOpts   = not . any isPkgDbOpts
+
+main = do args <- getArgs
+          defaultMainArgs $ if (length args > 0 && (head args `elem` ["configure", "install"]) && haveNotPkgDbOpts args)
+                              then (head args:"--user":tail args)
+                              else args
+            
diff --git a/hPDB.cabal b/hPDB.cabal
--- a/hPDB.cabal
+++ b/hPDB.cabal
@@ -1,40 +1,46 @@
 name:                hPDB
-version:             0.99
-stability:           beta
+version:             0.999
+synopsis:            Protein Databank file format library
 homepage:            https://github.com/mgajda/hpdb
+stability:           beta
 package-url:         http://hackage.haskell.org/package/hPDB
-synopsis:            Parser, print and manipulate structures in PDB file format.
 description:         Protein Data Bank file format is a most popular format for holding biomolecule data.
-
-  This is a very fast parser (below 7s for the largest entry in PDB - 1HTQ which is over 70MB - as compared with 11s of RASMOL 2.7.5, or 2m15s of BioPython with Python 2.6 interpreter.)
-
-  It is aimed to not only deliver event-based interface, but also a high-level data structure for manipulating data in spirit of BioPython's PDB parser. 
-
+                     .
+                     This is a very fast parser: below 7s for the largest entry in PDB - 1HTQ which is over 70MB - as compared with 11s of RASMOL 2.7.5, or 2m15s of BioPython with Python 2.6 interpreter.
+                     .
+                     It is aimed to not only deliver event-based interface, but also a high-level data structure for manipulating data in spirit of BioPython's PDB parser. 
 category:            Bioinformatics 
 license:             BSD3
 license-file:        LICENSE
 
 author:              Michal J. Gajda
-copyright:           Copyright by Michal J. Gajda '2009-'2012
+copyright:           Copyright by Michal J. Gajda '2009-'2013
 maintainer:          mjgajda@googlemail.com
 bug-reports:         mailto:mjgajda@googlemail.com
 
 build-type:          Simple
 cabal-version:       >=1.8
-tested-with:         GHC==7.4.1, GHC==7.0.3, GHC==7.4.2
---Need to re-test: GHC==6.12.1,  GHC==7.0.4, GHC==7.1.20101026 
+tested-with:         GHC==7.0.3, GHC==7.2.2, GHC==7.4.1, GHC==7.4.2, GHC==7.6.1, GHC==7.6.2
+extra-source-files:  README.md INSTALL AUTHORS
 
+source-repository head
+  type:     git
+  location: https://github.com/mgajda/hPDB
+
 flag have-mmap
-  description: Use bytestring-mmap to read input faster.
+  description: Use mmap to read input faster.
   default: True
 
 flag have-sse2
   description: Use -msse2 for faster code.
   default: True
 
-flag old-text-format
-  description: Use text-format versions before 0.3.0.9 (and define Params instance for 11-tuple to 20-tuple yourself.)
-               Disable for (yet unreleased) versions after 0.3.0.8 when change was merged into upstream.
+flag have-text-format
+  description: Do not use text-format, since it may require double-conversion
+               and thus linking of libstdc++ which may break compilation
+               due to GHC bug #5289:
+               .
+               http://ghc.haskell.org/trac/ghc/ticket/5289
   default: True
 
 flag old-bytestring
@@ -58,17 +64,15 @@
 
 Library
   ghc-options:      -fspec-constr-count=4 -O3 
-  build-depends:    base>=4.0, base <4.7, ghc-prim, directory, mtl, template-haskell, vector, AC-Vector, containers, deepseq, QuickCheck >= 2.5.0.0, text>=0.11.1.13
+  build-depends:    base>=4.0, base <4.7, ghc-prim, directory, mtl, template-haskell, vector, AC-Vector, containers, deepseq, QuickCheck >= 2.5.0.0, text>=0.11.1.13, iterable >= 1.0
   if flag(have-mmap)
-    build-depends: bytestring-mmap
+    build-depends: mmap
     cpp-options: -DHAVE_MMAP
-  if flag(have-sse2)
-    ghc-options: -fspec-constr-count=4 -O3 
-  if flag(old-text-format)
-    cpp-options: -DDEFINE_PARAMS_INSTANCES
-    build-depends: text-format <= 0.3.0.8
-  else
-    build-depends: text-format >= 0.3.0.9
+  -- These optimization options change a lot for GHC >= 7.4.1
+  ghc-options: -fspec-constr-count=4 -O3 
+  if flag(have-text-format)
+    cpp-options: -DHAVE_TEXT_FORMAT
+    build-depends: text-format >= 0.3.1.0
   if flag(old-bytestring)
     cpp-options: -DDEFINE_NFDATA_INSTANCE
     build-depends: bytestring <= 0.9.2.1
@@ -84,8 +88,8 @@
     build-depends: zlib <= 0.5.3.3
   else
     build-depends: zlib >= 0.5.4.0
-  other-extensions:       ScopedTypeVariables OverloadedStrings BangPatterns NoMonomorphismRestriction EmptyDataDecls MagicHash
-  other-modules:    Bio.PDB.EventParser.ParseATOM, Bio.PDB.EventParser.ParseCAVEAT, Bio.PDB.EventParser.ParseCISPEP, Bio.PDB.EventParser.ParseCONECT, Bio.PDB.EventParser.ParseCRYST1, Bio.PDB.EventParser.ParseDBREF, Bio.PDB.EventParser.ParseFORMUL, Bio.PDB.EventParser.ParseHEADER, Bio.PDB.EventParser.ParseHELIX, Bio.PDB.EventParser.ParseHET, Bio.PDB.EventParser.ParseHETNAM, Bio.PDB.EventParser.ParseHYDBND, Bio.PDB.EventParser.ParseIntRecord, Bio.PDB.EventParser.ParseJRNL, Bio.PDB.EventParser.ParseLINK, Bio.PDB.EventParser.ParseListRecord, Bio.PDB.EventParser.ParseMASTER, Bio.PDB.EventParser.ParseMatrixRecord, Bio.PDB.EventParser.ParseMODRES, Bio.PDB.EventParser.ParseObsoleting, Bio.PDB.EventParser.ParseREMARK, Bio.PDB.EventParser.ParseREVDAT, Bio.PDB.EventParser.ParseSEQADV, Bio.PDB.EventParser.ParseSEQRES, Bio.PDB.EventParser.ParseSHEET, Bio.PDB.EventParser.ParseSITE, Bio.PDB.EventParser.ParseSLTBRG, Bio.PDB.EventParser.ParseSpecListRecord, Bio.PDB.EventParser.ParseSPLIT, Bio.PDB.EventParser.ParseSSBOND, Bio.PDB.EventParser.ParseTER, Bio.PDB.EventParser.ParseTITLE, Bio.PDB.EventParser.ParseTVECT, Bio.PDB.EventParser.PDBParsingAbstractions, Bio.PDB.EventParser.FastParse, Bio.PDB.Util.MissingInstances, Bio.PDB.Common, Bio.PDB.InstantiateIterable, Bio.PDB.Iterable.Utils
+  other-extensions:       ScopedTypeVariables OverloadedStrings BangPatterns NoMonomorphismRestriction EmptyDataDecls MagicHash CPP PatternGuards NamedFieldPuns DisambiguateRecordFields TemplateHaskell MultiParamTypeClasses FlexibleInstances FlexibleContexts
+  other-modules:    Bio.PDB.EventParser.ParseATOM, Bio.PDB.EventParser.ParseCAVEAT, Bio.PDB.EventParser.ParseCISPEP, Bio.PDB.EventParser.ParseCONECT, Bio.PDB.EventParser.ParseCRYST1, Bio.PDB.EventParser.ParseDBREF, Bio.PDB.EventParser.ParseFORMUL, Bio.PDB.EventParser.ParseHEADER, Bio.PDB.EventParser.ParseHELIX, Bio.PDB.EventParser.ParseHET, Bio.PDB.EventParser.ParseHETNAM, Bio.PDB.EventParser.ParseHYDBND, Bio.PDB.EventParser.ParseIntRecord, Bio.PDB.EventParser.ParseJRNL, Bio.PDB.EventParser.ParseLINK, Bio.PDB.EventParser.ParseListRecord, Bio.PDB.EventParser.ParseMASTER, Bio.PDB.EventParser.ParseMatrixRecord, Bio.PDB.EventParser.ParseMODRES, Bio.PDB.EventParser.ParseObsoleting, Bio.PDB.EventParser.ParseREMARK, Bio.PDB.EventParser.ParseREVDAT, Bio.PDB.EventParser.ParseSEQADV, Bio.PDB.EventParser.ParseSEQRES, Bio.PDB.EventParser.ParseSHEET, Bio.PDB.EventParser.ParseSITE, Bio.PDB.EventParser.ParseSLTBRG, Bio.PDB.EventParser.ParseSpecListRecord, Bio.PDB.EventParser.ParseSPLIT, Bio.PDB.EventParser.ParseSSBOND, Bio.PDB.EventParser.ParseTER, Bio.PDB.EventParser.ParseTITLE, Bio.PDB.EventParser.ParseTVECT, Bio.PDB.EventParser.PDBParsingAbstractions, Bio.PDB.EventParser.FastParse, Bio.PDB.Util.MissingInstances, Bio.PDB.Common, Bio.PDB.Iterable.Utils
   exposed-modules:  Bio.PDB.EventParser.PDBEvents, Bio.PDB.EventParser.PDBEventParser, Bio.PDB.EventParser.ExperimentalMethods, Bio.PDB.EventParser.HelixTypes, Bio.PDB.EventParser.StrandSense, Bio.PDB.Structure, Bio.PDB.StructureBuilder, Bio.PDB.Iterable, Bio.PDB.IO, Bio.PDB.Fasta, Bio.PDB, Bio.PDB.Structure.Vector, Bio.PDB.Structure.Elements, Bio.PDB.Structure.List, Bio.PDB.StructurePrinter, Bio.PDB.EventParser.PDBEventPrinter, Bio.PDB.IO.OpenAnyFile
   exposed:          True
 
