cancle button for settings dialog and some code improvements