Hi jpadie :)
Unfortunately, maybe I did something wrong but your code doesn't seem to work with nested tags.
So, I started a different approach, with header tags first (because non nested), and from now I will try to find a way to add the deletion of empty divs and spans as well :
//...