Final commit+fixed internal leaks memory