The problem is caused by using SetDelayed in the definition of DG. The derivative is not evaluated until it is used, and when it is, it is a derivative with respect to a constant x. So, either use Set in the definition of DG or force evaluation prior to use.