Added error handling and corrected all known errors.