fixed exception handling. removed some unused imports

Ran unit tests, passes