Implement heartbeat

Closes #1