Move token resolution to plan building

o Write tests
o Add Materialize.mapValues