some changes based on refactors from MateUnity