refactor serde to remove some unecessary boxing and include dictionary awareness