Slightly improved error handling. Removed unused imports from driver.