Sample app works. Properly handle issues.

Sample application was not maintained after the fork. I have upgraded it
and it is working correctly now.

The code was not properly handling a few issues. These have been
corrected.