Merge non DirectX improvements from DirectX branch