Fixes from Petr on rebased PR 422
Merge pull request #427 from hflynn/agent_fix_dev

Fixes from Petr rebased