Added import of Exception.
Added various missing imports of Exception
Fixes for several detected type errors
Fixed type error