Matrix: Fix for compile error and memory leak