Tested matrix code and fixed bugs.