Add timeout support. Needs a bit of cleanup still