WIP: Added middleware
Improved resilience