Fixed a few bugs with timeout handling and exceptions in case of timeout