instance_dao: fixed breaking of flow on unrecognized master
js: refactored code into orchestrator.js (more to be done)