Inline some code in filter() + optimizations