Refactors to stop re-writing the DOM