fix more unused variable warnings

Those changes prevent more unused variable warnings to occur, in particular when building with -DNDEBUG, which disables asserts.