Critical fixes to texture handling