Refactor dbprint to enable selective debug output