Cleaned up global code