Fix an issue with persisting materials.