mods to the middleware to hopefully fix things