tons more work cleaning up globals