replaced all sprintf with snprintf to guarantee thre is no buffer overflow possible
fix for debug mode