Adding better handling of error conditions.