Add validation block and fix lots bugs.