changed main params
Plugged remaining memmory leaks.