Fix bad accesses and bad arguments.
Merge pull request #269 from Hywan/fix_example_api

Fix bad accesses and bad arguments