fix some issues with globals