Changing struct into class and encapsulating various functions