Fixes bugs with custom self-closing tags and empty custom tags.

Related to #880