Nicer matrix output, some code cleanup