Refactored a little bit.
Added mean squareed error calculation.