added support for dryrun, better support for state management, other minor fices