Add flatten function. It covers concatenate functionality as well.