Added missing braces to control statements. Braces errywhere please.
Refactoring: Removing unused imports.
Simplifying for-loops, where practical.