Moved matrix management from mouse handling function to Spatial