Add generics to fix casting problem.
Make exception catching more concise.
Remove unused imports.
Merge branch 'master' into refactor/generics

This incorporates the for loop refactor.
Introduce several "for each" loops to reduce clutter.
Merge pull request #37 from agouge/refactor/generics-and-for-each

More code cleanup