#17: using stack to capture function definition provenance. Adding global stack
#26: starting to provide python 3 support. Using generators to improve performance