Fix problem with nested functions and expressions