Added example.
Some refactoring.