Fix padding bug in GenerateSID(), spotted by @ShutterQuick
Added a function to replace all the ugly sprintf-ing everywhere