Oh, this is overkill. :-) I'm not going to split the codec up, that created too much duplication. There is no code that can be further shared between the client and the server - every use of the permanent keys is specific.

There are much better things to do than improve code endlessly. It works, is clean, and readable, and that's good enough for me.

Could you merge this? Thanks.