Improved handling of derived vars with reduce