Added middleware support
Reference errors