Fixed formatting and cleaner matrix code.