Fix a bug in the invocation of flattenDefinition