Fixes possible IllegalArgumentException.