Add globals and remove unused