Write an essay detailing the history of Hagia Sophia and the variety of functions this mosque has served. Include a detailed description of the architectural modifications (both structural and decorative) to the Hagia Sophia.