Move middleware classes to a common module