Fix various  [-Wunused-variable] and [-Wunused-function]