Fix handling of self-closing tags