Fixed bugs in ExResidFxn.R