Minor refactorings and small enhancements to example.