Tidy up eeagent heartbeats

Wait on the container's heartbeat function rather than sending a message to its own listener.

This pr also includes some general tidying.