fix memory leaks and update make