Replaced many sprintf calls with snprintf.