Eliminate with_val by generalizing value

To the best of my understanding, this should work perfectly, but testing with some more complex existing code would be good.