Improvements to GAMS code to eliminate NaNs