Fixed bugs in dgw introduced by last commit