Move serialisation of pseudorects into separate functions

Keeps the code clearer.
2 files changed