add python foreach, cleanup