Refactored a little bit and added in some cross validation stuff.