Add support for functions; update examples
Improve memory management of blocks