Various build fixes.
Fix generating empty files.

Because the switch returned false by default, the the traverse never
descended into child elements, thus skipping the entire tree from
processing.
Merge only if there are regions to merge.