fix iterator and cleaning up use of _file