Fix --g flag. Pass GHC --package-db option to Cabal query of installed packages. Read/Write index file with utf8 encoding to avoid IO errors.