avoid race condition when saving message
also mark as read in-browser message
fix double nick history
restructure js files
add missed readFlag