made search tree safe; still not perfectly balanced
cleaned up search tree code and fixed some bugs