Implement timeout (resolves #364)
Merge pull request #368 from Arcterus/timeout

Implement timeout