Remove the global text-tree string storage and make keyval a real class

The binary tree string storage for tag keys and values in text-tree.cpp is not thread-safe. The current code works around the issue by creating a new tree for each new tag list. That is not much more efficient than simply copying the strings around and has some bugs that cause memory leakage.

This pull request gets completely rid of the binary tree and replaces it with std::string for key and value that properly clean up after themselves. It also replaces the static functions in the keyval class by proper member functions, making the code a tiny bit more readable. 

This gets rid of most of the memory leaks (see #228) for me. The remaining leaks that valgrind shows are small one time allocations. I haven't tested the impact of this pull request on performance yet.
stray space