Use mapM.
Port to linear.
Cleanup of tests and things.
Merge pull request #1 from cchalmers/linear

Linear