move all this stuff to d2-common