Moved more logic to Global so we have to duplicate less in Spark