removed intval() calls and extracted (where possible) executing them for each loop iteration
added instance cache -- decreased php time on Special:Following