Introduce nasty abstractions.

Now this is C++. I somehow get the feeling this is overengineered.