Remove flash from context middleware and modify session management