Some code clean-up:
- Removed unused variables
- Added some missing variable declarations.
- Replaced for-in loops with for-loops where possible.
- Fixed some missing dependencies.
- Fixed some mixed indentation (now all tabs)