Fixed many inconsistencies when handling text nodes. Also added 'text' method, which appends a string as a text node.