Fix problems and lint the examples

This fixes linting, compatibility and error handling issues with the
examples.