Inprove filter selecting method.

Also fix memory leak while exting with packing methd non-empty.