memleak, double free, init fix