Added possibility of no timeout (=0)