Fix NPE being thrown due to null parameters