Fixes to error detection&handling.