This code is based on Splay 0.8.2, available from: http://my.netian.com/~polarb/