Changed all the sprintf into snprintf, removed an unused routine.