TWSD: fixed timeout, added timeout/delay as parameters.