Updated to work with GHC 7