I believe I have got this sorted. I had to fall back to loading the active theme right at the start, but this should be a fixed-length(ish) task, getting longer only if a theme has a ridiculous number of files.