added some comments and fixed connection issues (daemon not dies if
mysqlserver is gone away)