Added reconnect functionallity and small tweaks.