Improved resource handling for Texture2d.