cleanup & made to work on GHC 7.8