updated the AGM related code to work with SWIG