Feature/heartbeat

Heartbeat, per the spec. Also introduces multithreaded architecture.