Refined cross-domain font code and relocated to top of file