Converted to the new debug interface, using script written by Patrik