More flattening refactoring