Add universal custom functionality to Asterisk

Hi.
I am not a professional asterisk user.
There is Elastix (asterisk + freepbx) in our server.
There is a task to add some functionality to asterisk through custom dialplan.But the problem is that by upgrading asterisk,my custom dialplan doesn’t work very well because asterisk has another structure of directories for discussion record files,another macroses for recording,etc.
Is there a method for adding functionality to asterisk which will work on upgrated system in future?

  1. One cannot be sure what will change in the future.

  2. Without knowing the nature of the additional capability it is not possible to even guess the best way to miimise the risk.

  3. The use of FreePBX severely constrains the dialplan and this is the wrong forum to discuss the resulting constraints.