Move inheriting from extends into prepare.
Use a simpler way to make sure that global_app is at the base of
the extends chain.