code cleanup (handling of network socket activity)