Made set_implementation work again.

Also did some refactoring.