Fix NPE with invalid materials