Fixes for error handling