I have problems with variable declarations needed in earlier parts that are merged as later parts (making the compiler unhappy).
There is probably no one-size-fits-all answer. Posting some code and error messages will be necessary to solve your issue.