Changing hierarchy of classes