Refactor validation loop to improve and not use collapse/expand; fixes #21