improved sqlstore, fixed restore_state on queued runs