Tough slog to get flatten going with proper result types.