Add debugging messages and restructure output.