Table manipulations and selection

This is from #637.