Clean up code stolen from cabal

This addresses problems in #19