Improvments to textures handling