Rework tree search algorithm. Add some debugging commands to the interpreter