Refactoring and cleanup

- Updated several examples.
- Work-in-progress, some parts won't compile.