The problem with your formula had to do with your formula parameter names. In preMain, when defining formula parameters with the FunctionParameter class, you need to use the same name in main() that you used in preMain. For example, you were using pMALen in preMain and pMALength in main. There were a couple others. Below is a corrected version of your formula.
FYI, one way to solve this kind of crash you were experiencing is to comment out all the code in the formula and save it. Then line-by-line (or code block) uncomment a line, save and run the syntax checker until you find the offending piece of code.
Comment