fix issues #12 and an example of #15
Merge pull request #16 from bcipolli/fix_two_bugs

fix issues #12 and an example of #15