Added timeout support.

Fixes #1.