Dozens killed in Afghanistan fighting as foreign troops head home