Fix an NPE and add soem debugMode checks before spamming the logs