Replaced func_globals with __globals__ for Python 3 compatiblity