Changed to matrices. Added integration method for mats.