Issue #8677 by turegjorup: Refactored serialisation to Middleware to use standard serialisation