Timeout

Add timeout setting and error throwing when timeout is exceeded.