Improved error handling and added timeout exceptions