Added support for custom functions, and a few other things