d3 drawing rectangles and dragging

I think the child elements of each `<g>` can be positioned relative to its position, could we try that instead of working out the absolute positions? It might also be why we have that offset problem we are seeing when we drag them.