Renamed appContext and moved before initialization