add middleware and change message types.