fixes two bugs related to static/dynamic variables