Removed logging to stderr and fixed timeout handling