refactor(flatten): simplify flattening code so there is no difference between call and member