remove check for null, reducing scan warnings
replace sprintf with snprintf and cleanups
bint initialized can be negative, reduce warnings reported by scan