Fix match_columns and emptiness test

Please check 8041824173740469eb390c1d01c23b04df6d27b7 especially, since I don't really know what I'm doing.