Fixes potential global reference leak on Android, by Philipp Wiesemann