Sonar Cleanup.

Use more generics, throw proper errors, misc formatting.  All in an
effort to clear sonar warnings on library.