Moves up line cleaning to handle empty lines better
Overhaul of generation tree.