Fixed bugs in sending/receiving KeepAlive messages.