Added clickOutside directive, also improved filter logic.