Adding query commit code; minor tweaks