Memory optimizations and minor cleanup

Those matches were creating a tuple unnecessarily ... a minor change. Also found another case where we flush when we shouldn't, and deleted some dead code.