Rewrite parts of balanced-node library