Generic flattener.