Improved Error Handling and Cleanup and Bug Fixes.