Move cast to parent function
Remove cast
Remove unused imports/locals
Add generics
Add generics
Correct static access warnings
Merge pull request #1436 from gliptak/genericswarnings

Correct warnings