Introduce a debug info builder.

Moves all code from todebug into a new class.