Improved dev demos, and fixed some bugs revealed by them.
Added test for defining functions in functions.