clean up code, fix memory leak