Treebrowser: exclude false-positives, fix memory leaks

This leak was found by cppcheck. Also reduced scope of dir variable.

Note: this partially covers #125.