Fixed issues with reconnection and JS polling