Fixed matrix errors