Form API AuthenticationMiddleware, Form API refactoring