Moved make_app to the bottom so the code is easier to follow.