Move Matrix to a separate module