Sonar Cleanup.

Use more generics, throw proper errors, misc formatting.  All in an
effort to clear sonar warnings on library.
Merge pull request #4 from hazendaz/master

Sonar Cleanup.