Fix a few variables might be used before assignment

Also fix a few missing string formatting placholders