Fixing race conditions in connections and cleanup
cleanup