better debug handling