Update sample app, fix some timing bugs.