Removed lines from middleware that kept raising 500 errors.