Fix Global Leaks

Fixed global function leaks