Fixed heartbeat thread and startup/shutdown races in TaskManager
Fix concurrency bugs in cluster manager and cluster manager tests.
Simplifications of instance loading at startup.