take 2 on the algorithm

more conducive for making a visual tree out of it
fix some ignores