Sync some fixes from Amanda.