Improved debug

Merged with tools.