fixed some bugs. This should hopefully work if we can now tackle the overfitting problem