Finished model implementation from lecture 2.