cleanup, and locks queries