Minor improvements to createDOM function