Reintegration

Commits from integration branch without agent/worker communication refactoring and tests
Shouldn't this be a state variable?

0 - Disconnected
1 - Connecting
2 - Connected