Fixed several material bugs