added recover_autosample state, misc cleanups