Refactored Connection and Connection Thread. Added LoginDialog