Feature/middleware

Addresses Proposal #270