[MH,RG] add the timeout functionality and some minor fixes