improve middleware stack, add courier middleware