Fix condition for keepalive. Fixes issue #23