Fix unused variable warnings

This fixes -Wunused-variable and -Wunused-but-set-variable