Updated to reflect changes in the cpp
Moved keepalive packet check
Increased keepalive delay