Fixed memory leak when outbound query fails to check out for some reason, cleaned up some other minor issues.