moved stuff out of globals