fix a lot of stuff in binary protocol