Improved validation criteria. Fixes #4