Some changes to avoid exceptions.