Restructure thread management in relation to Android lifecycle