Minor refactoring in InstanceUtil.