fix expiry flag for the main thread; fix next target selection when expiry flag set
make sleep interval signed