Slight refactoring, but mainly in the example code