Fixes #29 by taking ownership of global variabls when reading them