Simplify Expansion and Value Expansion algorithms

... by processing keywords directly.

This addresses #218.