added support for init callback and autoconnect support