Integrated debug module and added some debug output.