Fixed bug that caused interferences between events and keepalives.