Clean up matrix code a tiny bit.