rewrite difficulty control and fix subtle bug in verify.c