Reworked some code to avoid some unnecessary calls to giveMaterial() in order to improve interoperability with layered cross-sections.