Fix cleanup on errors for load_mid