Add a cleanup query; improve expr handling