Changed dom node attachment order to prevent bugs.