Improvements to debug core to allow templating