Fix various warnings

- Fix imports that are not used
- Fix exported variables from case or if statements
- The problems are important when warnings_as_errors is turned on
enable more warnings