This code is now pretty tight

All data structures have been tested under valgrind and there are no memory
leaks or invalid writes.
Finally, something that beats red-black trees
Experimenting...