adding setTimeout to ensure tree is not redrawn until all changes are ready. code review please!