Fix memleak, TreeBuilder, Config and Parent commit

those C resources wasn't freed properly, causing memory leak.