Code improvements in poll_activities() function.