Improve debug handling + debug output