Modify the way app is called

Due to first time loading issues, defining app on the global scope cause
errors.