Expose 'flatten' function