Refactored validator to make it easier to work with. Still not happy.