Initial refactor of shapefile value handling functions. Untested.