Removed extra stuff, fix memory leak