Fix some issues relating to materials