Optimize string extraction functions.