inline static en/decode methods, need to refactor this, ugly