Fix unused imports and reuse of variable