fixes ApplicationName is $null, adds debug logging