Order of initialisation for Lua code blocks

Hi, using the most recent firmware (I’ve not updated for a while!) i’ve started having issues with my lua code. Because of the (incredibly annoying) code block size limits i’ve had to split my code up across the setup pages of the various elements, as well as the general block setup page. In the past this worked, but now when I initialize the block I get issues about code not being callable. If I go in and edit the code and save it works again, but then when I disconnect and reconnect I get errors, so it must be to do with order of initialisation. What is the correct way to structure a complex program to make it work? In what order should the functions be added to the elements so that everything can see everything else?

I have to say that the most annoying part of these controllers is the code block size limits, they make setting up anything complex way more difficult than it needs to be, and the size restrictions seem so arbitrary, it would be really nice to have an option which just imposed a global code size limit that you could use across all the elements, so I could put all of my program code inside the block setup, and then just call it with a line or two from the elements themselves, it would make it much better in terms of reasoning about your program as well.