adds proper handling of keep-alive signal.