refactor serde to remove some unecessary boxing and include dictionary awareness

@Lordshinjo and @mickaellcr you might want to take a look