Fixed bugs with generating materials