Code cleanup for D3