fixes to timedwait, mainly fix return value