optimizing sequential scans; still hunting down a segfault under certain conditions