Updated with some more debug logging if you manually turn debug on