Without checking your code:
The most time consuming constructs in an interpreting language are high level Do-loops and nested logical branchings by unstructrured Ifs.
Replace Do constructs by Mapping functions into arays.
Replace Piecewise and Which constructs by conditonal definitions where possible. If prcecison is not an issue, Replace slow evaluating functions by an Interpolation.
Try to avoid any overhead by logical tests, if they are not unavoidable in the current run.