Modularize filter, and combine with distinct
Move function and array utilities to base module