Clean up exceptions.

Be specific about which exceptions are thrown.
Only declare exceptions as thrown if they are actually thrown.
Merge pull request #1139 from thobe/2.0-exceptions-cleanup

Clean up exceptions.