Nested function support - only mildly tested