Fix possible crash bug, remove useless casts to const chars, and remove duplicate macro getStatName().