Several changes to improve efficiency of StructAlign, by caching
frequently-used matrices. Gains are quite significant.