function as a filter, and minor fixes.