Convert frame guard to middleware.
Fix directory.