prevalidation refactoring and fixes