Shapefile correction

And some bonus fixes. See commit messages.