bugfixes in heartbeat encoding and integer encoding