Try real hard to handle closing tags

I should really just throw this out and hook up an XML parser.