Fix crash caused by Unit refactoring