Fix exception in query rewriting,  fix usage of d2 names in curli and console