Clean up exceptions.

Be specific about which exceptions are thrown.
Only declare exceptions as thrown if they are actually thrown.