more refactoring of gd.cc