Change termIndex to be BST type, remove mergesort

Signed-off-by: Bryan Reilly <94bryanr@gmail.com>