Optimize userinfo-related loops