Fixing unkown issues

Fixes some issues that are happening with the middleware like #26 and #27