Fixed error handling.