Fix misplaced ifdef and unused variable