Fix problem with reusing uids (of materials)