Changed hasID -> hasMaterial, hasData -> hasMaterialData
Added missing null checks