Significantly improve speed of value set loading

It's not the prettiest code, but with 64 measures loaded it reduces the time to load value sets on my machine from ~10 seconds to ~2 seconds.

I left in the commented out original "clean" code so that the intent is clearer to anyone looking at it.