modifying middleware structure, docs