Code style fixes

- Removed unused variables
- Fixed implicitly declared variables
- Fixed duplicate variable declarations
- Fixed trailing commas in hashes
- Replaced tabs with spaces
- Added default labels to switch statements
- Added missing semicolons