Fix more nested function issues