(D3D) Move code around