Filtering implemented. Also fixed bugs with closing dialogs