Only use binary format for types we can decode

And simplify state handling in Connection gen_server.