progress on refactoring and hd_train_2