Fixed bugs in texture loading.