Use GList functions instead of looping.