Added hash tree destructors, also some refactoring.