Fixed some bugs in texture binding