Turning viewModel variable local and minor refactorings