Fix nested scalar functions