Add cabal sandbox support and clean up some code