Help streamlining script?

I just finished a script meant to get the glass area for all windows in all rooms and export it to Excel. Tried it on a smaller project and it works fine, however when I run the script on a larger project it never completes(gave it half an hour). I’m thinking it’s because there are too many rooms and windows to calculate? And perhaps this can be fixed by streamlining my(probably) ugly code?

By the way, a prerequisite for running the script is that all windows and doors have the room name entered in the comments parameter. I have a separate very simple script for achieving this. Will probably change this to create a dedicated parameter instead later on.

Script: https://drive.google.com/file/d/1DSxzT0PV6aCsmTvp5GzSikY3XqYgAMVQ/view?usp=sharing