You have demonstrated great insight into the challenges of being a referee in an RPG. You will find your way. Here are a few tips that I can convey as I have made nearly every referee mistake possible. ;)
To help remember things engage your players in the story. Have them do recaps of the show so far, the session night and even a what happened last time. It is shocking how much we forget as referees even though we have created the scenario and taken notes. Collective memory for a collective experience. There will be errors. There will be retcons (which we used to call post factualization). That is the nature of improvised collective experiences.
Preparation is good. However the game is there for the whole table and "letting your darlings" go is even more important in collective experiences as it is in writing. Consider the elements that don't get used as future ideas. It is more important to balance referee and player needs. I am sure there are multiple threads here about "rail roading" vs "sand boxing" if the table is happy (this includes the referee) then you are doing stuff right. It is also okay to have a debrief once in a while after session. Players can let the referee know what is working for them and vice versa.
I have been improvising comedy for a long time and being able to do things out of the blue takes practise. It also takes specific practice in narrative and listening. Making things work out of the box like a board won't ever happen in an RPG. Even a board game requires everyone to learn the rules and story. Learn to prep with checklists. Sometimes even flowcharts are needed. Notes should be one or two word reminders never sentences.
Troika looks insanely wonderful. A game after my cybernetic heart. There is a free online resource about improv comedy at learnimprov.com. this is my site but it is CC 4.0 and comletely free of charge, or tracking, or remuneration