fix handling for empty tags and text-handling