Improve performance of filter functions

Use .filter instead of checking each value and splicing
This is much faster, now the plotting (draw) part is the slowest part