Exception handling and bug fixes.