Improved debug handling.