Removed session.flush from Preference.set_filter_active. It isn't needed as pointed out by @pypingou