Improved debug funcionality