Moved some Model logic to the model file.