Fixed major bug in validation code; also switched validation from cached version to simpler and only slightly slower version