pluggable mailnotify and some minor refactorings