cleaned more code; added automated tuning for hyperparameters