Add support for flatten