Some minor refactor. Also make domain and subdomain not mandatory
Adding a minimum timeout before reconnecting