morning improvements

hacks to call external functions and support for declaring them
more intrinsic functions (cos, pow, sin, sqrt)
bug fixes for max and min intrinsic functions