Fix Ag functions

I believe this is what is intended? It was not working for me like it was...
Merge pull request #474 from lfilho/patch-1

Fix Ag functions
Merge branch 'master' into jby

* master:
  Fix Ag functions