refactor cleanup of connections