Fixed memleaks