Fixes a bug in material loading