Cleanup and improved error handling of def files.