add missing defines.h; fix several matrix multiplication confusions.