fix memleak + add log