Cosmetic improvements.

Remove unused imports and local variables.
Add generic types to remove compilation warnings.