Refactor how middleware works, now using Transformer instead of lambda expression.