change recover rules
re-orgonize the code structure, add optimize mode