Bug fixes to initialize the matrices properly.