clean up matrix.py & square matrices