fixed: dead end detection
fixed: memory leaks when printing matrix