fixed reconnect
typos
remove debug
added strlaststr()
fixed bug on broker restart