Use API functions rather than globals