Some refactoring of neural net and predict method.