Refractor to resolve global pointer usage and call structure