Compute maxlen in JS.
Simplified parsing of "states" block.
Move all the structure building to JS.
Put props in JSON too.