Fix nested type serialization

(cherry picked from commit e6ed989941d9e6dc92ed1e411a9a7f08862c8b32)
Style consistency

(cherry picked from commit 26c0858d6a3867d11153f278528dfcb100443332)