rewrite binary proto, fixed bugs