Fix connection and js bugs