Move layout loading outside loop and remove useless unset.