add script to run all examples

fix a few bugs in the examples