major rewrite of Dom data structure