imlement settings dialog: add/edit templates; fix some issues