Ignores textnodes that only contain whitespaces and is adjacent to blocks.
Lots of bug fixing and optimization.