Correct code generation and MapPairs serialisation