Implemented keepalive_maxcount

Fixes #197