Fixed bugs in texture manager