Fixed some memory leaks due to unallocated PETSc matrices.