Fixed bug with app crash on entering background