Added a function to replace all the ugly sprintf-ing everywhere