Remove no-longer needed calls to require().
Replace deprecated max() operator by maximum().
Use NLsolve package instead of embedded solver.

By the way, change static and dynamic model functions so that they modify
arguments in-place instead of returning newly allocated arrays.