Moved table.flatten to tablehelper