matrix multiply fix / code cleanup