Implement basic middleware.