Avoid memory leak & shared lib support