Cleaned up some unused imports and fixed missing exception handling.