Clean compile with CMAKE_BUILD_TYPE=RELEASE

Fix unused-variable warnings when building with CMAKE_BUILD_TYPE=RELEASE