Removed unused imports & added checks in onResume