unify error handling in validator + style fixes