iterator closing and small fixes