Minor improvements (and hacks) in error handling.