First implementation of the buffer tree code.