enhance debug log
fix bug: add lock to session manager, to avoid session stop called multi times
improve the writing synchronization
catch the exception prone code
minor improve