Added ability to serialize a perceptron and refactored code to assign responsibilities more sensibly