cleanup code, rewrite the doc in MD format