Fix some things for empty slices.

And add tests.