fixed some bugs in materials