Fix closure middleware support