Reintegration

Commits from integration branch without agent/worker communication refactoring and tests
This is a design decision, we are going to calculate state changes in the Angular controller rather than having the agent or worker do it. In the next PR, the scheme we use here is built upon.