changed global storage to use Flask.g for threaded environment