Fix validation method and minor cleanups.