Proper alloc usage, fix mem leak.