cleanup & socket close improvements