added relogin, reconnection, changed pointer allocation