Created ConnectionHandling

Created a ConnectionHandling class with Connect() and CloseConnection() methods so they could be used in all the other functional methods instead of duplicating the code in each function.