tweaking error handling for multi-threaded optimset