Improved exceptions handling