Fix a bug in the sample applications

Fixes issue #2