Added input validation to mlg.filter to prevent certain crashes.