add docstrings, some info messages and connection closing