fix memory issues.