Fix horrible bug with materials output