Fix for unpickable exception crashes (fixed in 2.5, backported)