Rename max to ag_max. Fixes #469