first, read up ambiguous sentences on wiki
who can refer to three things - It, the red haired girl or the blonde. now it refers to the red hair, so not much confusion there. in such cases it is best to use a comma(or atleast what i do)
'It was the red haired girl, standing behind the blonde...