Add the dom implementation and fix the API