Added basic configurable post-run actions.
Agent thread code refactoring.

* Moved to finite state automaton approach, may be handy when
implementing more flexible process.
* No test case analysis right now...