More work to get rid of python global variables, DO NOT USE yet