Revert "Fix accidentally broken things after removing unused variables"

This reverts commit 02b3a57998473432611a631cc8f15df6d0e3d1ab.
Revert "Remove unused variables"

This reverts commit bedd08ba5d81b706216f41414fddccb1cc7e4b30.
Remove unused vars (but not unused params)