Make flatten work