Fix use of globals