Refactored d3d9 a bit